| 123456789101112131415161718192021222324252627 |
- using Application.Abstractions.Data;
- using Application.Abstractions.Messaging;
- using SharedKernel.Results;
- using Domain.Entities.Donations.ValueObject;
- using Microsoft.EntityFrameworkCore;
- namespace Application.Features.Api.Crew.EndSession;
- internal sealed class Handler(IAppDbContext db) : ICommandHandler<Command, Result>
- {
- public async Task<Result> Handle(Command request, CancellationToken ct)
- {
- var session = await db.CrewSession
- .FirstOrDefaultAsync(s => s.ID == request.CrewSessionID && s.Status == CrewSessionStatus.Active, ct);
- if (session is null)
- {
- return Result.Failure(Error.NotFound("Crew.ActiveSessionNotFound", "활성 세션을 찾을 수 없습니다."));
- }
- session.End();
- await db.SaveChangesAsync(ct);
- // 쪽지 발송은 Endpoint에서 처리
- return Result.Success();
- }
- }
|