isn/src/isnd/Data/Packages/Package.cs

56 lines
1.3 KiB
C#

3 years ago
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
2 years ago
using System.Linq;
3 years ago
using isnd.Interfaces;
using Newtonsoft.Json;
namespace isnd.Data.Packages
{
public class Package
3 years ago
{
[Key]
[Required]
[StringLength(1024)]
public string Id { get; set; }
[Required]
[ForeignKey("Owner")]
public string OwnerId { get; set; }
[StringLength(1024)]
public string Description { get; set; }
public bool Public { get; set; }
[JsonIgnore]
virtual public ApplicationUser Owner { get; set; }
[JsonIgnore]
public virtual List<PackageVersion> Versions { get; set; }
/// <summary>
/// Latest version at put, posted,
/// or even deletion when no more active version.
/// </summary>
/// <value></value>
[Required]
[JsonIgnore]
[ForeignKey("LatestCommit")]
3 years ago
public long CommitNId { get; set; }
3 years ago
[NotMapped]
public string CommitId { get => CommitNId.ToString(); }
public virtual Commit LatestCommit { get; set; }
2 years ago
internal string GetLatestVersion()
{
return Versions.Max(v => v.NugetVersion)?.ToFullString();
2 years ago
}
3 years ago
}
}