diff options
| author | Jake Mannens <jake@asger.xyz> | 2023-08-22 22:59:59 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2023-08-22 22:59:59 +1000 |
| commit | c42362f8906eaf1021655da5ca0fe71ba1ec4a6b (patch) | |
| tree | f162d43e330abcf46fc9cf63538b5275547311a7 /Services | |
| parent | be4496b110e68e2c5a8f76f8ed770e9818befd68 (diff) | |
Fixed media description editing
Diffstat (limited to 'Services')
| -rw-r--r-- | Services/MediaService.cs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Services/MediaService.cs b/Services/MediaService.cs index 05dd5b0..953fd73 100644 --- a/Services/MediaService.cs +++ b/Services/MediaService.cs @@ -3,6 +3,11 @@ namespace HyperBooru.Services; public interface IMediaService { + public void SetDescription( + Media media, + string? shortDescription, + string? longDescription); + public void SetIngest(Media media, bool ingest); } @@ -18,11 +23,30 @@ public class MediaService : IMediaService { .First(td => td.Guid == HBContext.IngestTag); if(ingest) - media.Tags.Add(new() { TagDefinition = ingestTag }); + media.Tags.Add(new(ingestTag)); else media.Tags.Remove( media.Tags.First(t => t.TagDefinition.Guid == ingestTag.Guid)); db.SaveChanges(); } + + public void SetDescription( + Media media, + string? shortDescription, + string? longDescription) { + + using var db = dbFactory.CreateDbContext(); + var m = db.Media.First(m => m.Guid == media.Guid); + + if(string.IsNullOrEmpty(shortDescription)) + shortDescription = null; + if(string.IsNullOrEmpty(longDescription)) + longDescription = null; + + m.ShortDescription = shortDescription; + m.LongDescription = longDescription; + + db.SaveChanges(); + } } |
