summaryrefslogtreecommitdiff
path: root/Services/MediaService.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-08-15 15:49:14 +1000
committerJake Mannens <jake@asger.xyz>2025-08-18 10:59:32 +1000
commit38c60cee378b9c2ad42fc9dc79bc492b919a68f5 (patch)
tree6b62f84aab4b7866432e5da8ae8fcb889795d58b /Services/MediaService.cs
parent07a4c7ead01514bd3f304f00abc38140a1d73634 (diff)
Convert Razor pages to Blazor
Diffstat (limited to 'Services/MediaService.cs')
-rw-r--r--Services/MediaService.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Services/MediaService.cs b/Services/MediaService.cs
new file mode 100644
index 0000000..be2657a
--- /dev/null
+++ b/Services/MediaService.cs
@@ -0,0 +1,28 @@
+using Microsoft.EntityFrameworkCore;
+
+namespace HyperBooru.Services;
+
+public interface IMediaService {
+ public void SetIngest(Media media, bool ingest);
+}
+
+public class MediaService : IMediaService {
+ private IDbContextFactory<HBContext> dbFactory;
+
+ public MediaService(IDbContextFactory<HBContext> dbFactory) =>
+ this.dbFactory = dbFactory;
+
+ public void SetIngest(Media media, bool ingest) {
+ using var db = dbFactory.CreateDbContext();
+ var ingestTag = db.TagDefinitions
+ .First(td => td.Source == TagSource.Internal && td.Name == "ingest");
+
+ if(ingest)
+ media.Tags.Add(new() { TagDefinition = ingestTag });
+ else
+ media.Tags.Remove(
+ media.Tags.First(t => t.TagDefinition.Guid == ingestTag.Guid));
+
+ db.SaveChanges();
+ }
+}