diff options
| author | Jake Mannens <jake@asger.xyz> | 2023-08-22 22:59:59 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2025-08-19 23:33:14 +1000 |
| commit | 1cebdd5278155eedb3da8959322133df17625c6c (patch) | |
| tree | 14430740a2909ea0bc60e4cfa19775181684c852 /Services/MediaService.cs | |
| parent | ff715df3ccda51c1bb3d4b84f4391b4fdd1962dd (diff) | |
Fixed media description editing
Diffstat (limited to 'Services/MediaService.cs')
| -rw-r--r-- | Services/MediaService.cs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Services/MediaService.cs b/Services/MediaService.cs index 05dd5b0..a8b0406 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,33 @@ 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); + + shortDescription = shortDescription?.Trim(); + longDescription = longDescription?.Trim(); + + if(string.IsNullOrEmpty(shortDescription)) + shortDescription = null; + if(string.IsNullOrEmpty(longDescription)) + longDescription = null; + + m.ShortDescription = shortDescription; + m.LongDescription = longDescription; + + db.SaveChanges(); + } } |
