namespace Brizco.Core.EntityServices.Handlers.ShiftPlans; public class CompleteShiftPlanCommandHandler(IMediator mediator, IRepositoryWrapper repositoryWrapper) : IRequestHandler { public async Task Handle(CompleteShiftPlanCommand request, CancellationToken cancellationToken) { var shiftPlan = await repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == request.Id, cancellationToken); if (shiftPlan == null) throw new AppException("Shift plan not found", ApiResultStatusCode.NotFound); shiftPlan.CompletePlan(request.CompleteDescription, request.CompletePercent); repositoryWrapper.SetRepository().Update(shiftPlan); await repositoryWrapper.SaveChangesAsync(cancellationToken); await mediator.Send(new CompleteActivitiesCommand(request.CompleteActivities), cancellationToken); var shiftPlanUsers = await repositoryWrapper.SetRepository() .TableNoTracking.Where(s => s.ShiftPlanId == request.Id) .Select(ShiftPlanUserMapper.ProjectToSDto) .ToListAsync(cancellationToken); foreach (var shiftPlanUser in shiftPlanUsers) { var message = $"{shiftPlanUser.UserFullName}"; } return true; } }