Add prompt marketplace interactions and profile prompt tabs
This commit is contained in:
1 parent
691bc72681
commit
c95319b1fe
20 files changed
+734
-146
No files matched your search
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace OnlyPrompt.Backend.Database.Models
|
||||
{
|
||||
public class PromptLikeModel
|
||||
{
|
||||
[ForeignKey(nameof(Prompt))]
|
||||
public Guid PromptId { get; set; }
|
||||
public virtual PromptModel Prompt { get; set; }
|
||||
|
||||
[ForeignKey(nameof(User))]
|
||||
public Guid UserId { get; set; }
|
||||
public virtual UserModel User { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -25,13 +25,11 @@ namespace OnlyPrompt.Backend.Database.Models
|
||||
[MaxLength(200)]
|
||||
public required string Title { get; set; }
|
||||
|
||||
[MaxLength(4000)]
|
||||
public required string Prompt { get; set; }
|
||||
|
||||
[MaxLength(1000)]
|
||||
public required string Description { get; set; }
|
||||
|
||||
[MaxLength(4000)]
|
||||
public string? ExampleOutput { get; set; }
|
||||
|
||||
public string? ExampleImageUrl { get; set; }
|
||||
@@ -48,5 +46,7 @@ namespace OnlyPrompt.Backend.Database.Models
|
||||
[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>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace OnlyPrompt.Backend.Database.Models
|
||||
{
|
||||
public class PromptSaveModel
|
||||
{
|
||||
[ForeignKey(nameof(Prompt))]
|
||||
public Guid PromptId { get; set; }
|
||||
public virtual PromptModel Prompt { get; set; }
|
||||
|
||||
[ForeignKey(nameof(User))]
|
||||
public Guid UserId { get; set; }
|
||||
public virtual UserModel User { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ namespace OnlyPrompt.Backend.Database
|
||||
public DbSet<SubscriptionTierModel> SubscriptionTiers { get; set; }
|
||||
public DbSet<SubscriptionModel> Subscriptions { get; set; }
|
||||
public DbSet<ReviewModel> Reviews { get; set; }
|
||||
public DbSet<PromptLikeModel> PromptLikes { get; set; }
|
||||
public DbSet<PromptSaveModel> PromptSaves { get; set; }
|
||||
|
||||
public OnlyPromptContext(DbContextOptions<OnlyPromptContext> options) : base(options)
|
||||
{
|
||||
@@ -85,6 +87,36 @@ namespace OnlyPrompt.Backend.Database
|
||||
.WithMany(t => t.Subscriptions)
|
||||
.HasForeignKey(e => e.SubscriptionTierId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<PromptLikeModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.PromptId, e.UserId });
|
||||
|
||||
entity.HasOne(e => e.Prompt)
|
||||
.WithMany(p => p.Likes)
|
||||
.HasForeignKey(e => e.PromptId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasOne(e => e.User)
|
||||
.WithMany()
|
||||
.HasForeignKey(e => e.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<PromptSaveModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.PromptId, e.UserId });
|
||||
|
||||
entity.HasOne(e => e.Prompt)
|
||||
.WithMany(p => p.Saves)
|
||||
.HasForeignKey(e => e.PromptId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
entity.HasOne(e => e.User)
|
||||
.WithMany()
|
||||
.HasForeignKey(e => e.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user