53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using OnlyPrompt.Backend.Database.Core;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace OnlyPrompt.Backend.Database.Models
|
|
{
|
|
[Index(nameof(Slug), IsUnique = true)]
|
|
public class PromptModel : EntityBase, IHasSlug
|
|
{
|
|
[Required]
|
|
[ForeignKey(nameof(Creator))]
|
|
public Guid CreatorId { get; set; }
|
|
|
|
[DeleteBehavior(DeleteBehavior.Cascade)]
|
|
public virtual UserModel Creator { get; set; }
|
|
|
|
[Required]
|
|
[ForeignKey(nameof(Category))]
|
|
public Guid CategoryId { get; set; }
|
|
|
|
[DeleteBehavior(DeleteBehavior.Cascade)]
|
|
public virtual CategoryModel Category { get; set; }
|
|
|
|
[MaxLength(200)]
|
|
public required string Title { get; set; }
|
|
|
|
public required string Prompt { get; set; }
|
|
|
|
[MaxLength(1000)]
|
|
public required string Description { get; set; }
|
|
|
|
public string? ExampleOutput { get; set; }
|
|
|
|
public string? ExampleImageUrl { get; set; }
|
|
|
|
public decimal? Price { get; set; }
|
|
|
|
[MaxLength(ModelConstants.MaxSlugLength)]
|
|
[Column(TypeName = "citext")]
|
|
public required string Slug { get; set; }
|
|
|
|
[ForeignKey(nameof(SubscriptionTier))]
|
|
public Guid? SubscriptionTierId { get; set; }
|
|
|
|
[DeleteBehavior(DeleteBehavior.SetNull)]
|
|
public virtual SubscriptionTierModel? SubscriptionTier { get; set; }
|
|
public virtual IList<ReviewModel> Reviews { get; set; } = new List<ReviewModel>();
|
|
public virtual IList<PromptLikeModel> Likes { get; set; } = new List<PromptLikeModel>();
|
|
public virtual IList<PromptSaveModel> Saves { get; set; } = new List<PromptSaveModel>();
|
|
}
|
|
}
|