| 12345678910111213141516171819202122232425 |
- using Application.Abstractions.Data;
- using Application.Abstractions.Messaging;
- using SharedKernel.Results;
- using Microsoft.EntityFrameworkCore;
- namespace Application.Features.Api.Crew.DeleteWidgetConfig;
- internal sealed class Handler(IAppDbContext db) : ICommandHandler<Command, Result>
- {
- public async Task<Result> Handle(Command request, CancellationToken ct)
- {
- var config = await db.CrewWidgetConfig
- .FirstOrDefaultAsync(c => c.ID == request.ID && c.ChannelID == request.ChannelID, ct);
- if (config is null)
- {
- return Result.Failure(Error.NotFound("CrewWidget.NotFound", "설정을 찾을 수 없습니다."));
- }
- db.CrewWidgetConfig.Remove(config);
- await db.SaveChangesAsync(ct);
- return Result.Success();
- }
- }
|