namespace Brizco.Core.EntityServices; public class ShiftPlanService(IMediator mediator, IActivityService activityService, IRepositoryWrapper repositoryWrapper) : IShiftPlanService { public async Task ChangeShiftPlanTaskStatusAsync(Guid shiftPlanId, bool isChangeToShift, bool isDisable) { var shiftPlan = await mediator.Send(new GetShiftPlanQuery(shiftPlanId)); } public async Task CreateAsync(CreateShiftPlanCommand createShiftPlanCommand, CancellationToken cancellationToken) { var shiftPlan = await mediator.Send(createShiftPlanCommand, cancellationToken); await activityService.CreateActivitiesByShiftPlan(shiftPlan.Id, cancellationToken); await mediator.Send(new CreateShiftPlanNotificationsCommand(shiftPlan.Id,true), cancellationToken); return true; } public async Task UpdateAsync(UpdateShiftPlanCommand updateShiftPlanCommand, CancellationToken cancellationToken) { await mediator.Send(updateShiftPlanCommand, cancellationToken); await activityService.UpdateActivitiesByShiftPlan(updateShiftPlanCommand.Id, cancellationToken); return true; } public async Task CompleteShiftPlanAsync(Guid id, CompleteShiftPlanRequestDto requestDtos, CancellationToken cancellationToken) { var shiftPlan = await repositoryWrapper.SetRepository() .TableNoTracking.FirstOrDefaultAsync(s => s.Id == id, cancellationToken); if (shiftPlan == null) throw new AppException("Shift plan not found", ApiResultStatusCode.NotFound); shiftPlan.CompletePlan(requestDtos.CompleteDescription,requestDtos.CompletePercent); repositoryWrapper.SetRepository().Update(shiftPlan); await repositoryWrapper.SaveChangesAsync(cancellationToken); await activityService.CompleteActivitiesAsync(requestDtos.CompleteActivities, cancellationToken); return true; } }