-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IHS-58 Add delete tags handler and endpoint (#72)
- Loading branch information
Showing
4 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
ImageHosting.Storage/Features/Images/Handlers/DeleteTagsHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using ImageHosting.Persistence.DbContexts; | ||
using ImageHosting.Persistence.ValueTypes; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace ImageHosting.Storage.Features.Images.Handlers; | ||
|
||
public interface IDeleteTagsHandler | ||
{ | ||
Task DeleteAsync(ImageId id, IReadOnlyList<string> tags, CancellationToken cancellationToken = default); | ||
} | ||
|
||
public class DeleteTagsHandler(IImageHostingDbContext dbContext) : IDeleteTagsHandler | ||
{ | ||
public Task DeleteAsync(ImageId id, IReadOnlyList<string> tags, CancellationToken cancellationToken = default) | ||
{ | ||
return dbContext.ImageTags | ||
.Where(it => it.ImageId == id && tags.Contains(it.TagName)) | ||
.ExecuteDeleteAsync(cancellationToken); | ||
} | ||
} |