PortBlog.API/PortBlog.API/Entities/Post.cs

52 lines
1.2 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PortBlog.API.Entities
{
public class Post : BaseEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int PostId { get; set; }
[Required]
[MaxLength(100)]
public string Slug { get; set; } = string.Empty;
[Required]
[MaxLength(100)]
public string Title { get; set; } = string.Empty;
[Required]
[MaxLength(200)]
public string Description { get; set; } = string.Empty;
[Required]
[MaxLength(200)]
public string[] Categories { get; set; } = [];
[MaxLength(100)]
public string? Author { get; set; }
[Url]
[MaxLength(200)]
public string PostUrl { get; set; } = string.Empty;
public int Likes { get; set; } = 0;
public int Views { get; set; } = 0;
public int Comments { get; set; } = 0;
[MaxLength(200)]
public string? Image { get; set; }
[Required]
[MaxLength(200)]
public string BlogUrl { get; set; } = string.Empty;
[ForeignKey(nameof(BlogUrl))]
public Blog? Blog { get; set; }
}
}