namespace Brizco.Repository.Handlers.Shift; public class UpdateShiftCommandHandler : IRequestHandler { private readonly IRepositoryWrapper _repositoryWrapper; public UpdateShiftCommandHandler(IRepositoryWrapper repositoryWrapper) { _repositoryWrapper = repositoryWrapper; } public async Task Handle(UpdateShiftCommand request, CancellationToken cancellationToken) { var shift = await _repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.id); if (shift == null) throw new AppException("Shift not found", ApiResultStatusCode.NotFound); var newShift = Domain.Entities.Shift.Shift.Create(request.Title, request.Description, request.StartAt, request.EndAt); newShift.Id = request.id; _repositoryWrapper.SetRepository() .Update(newShift); await _repositoryWrapper.SaveChangesAsync(cancellationToken); return true; } }