public async Task <Response <WorkingHour> > Handle(GetWorkingHourByIdQuery query, CancellationToken cancellationToken) { var workingHour = await _workingHourRepository.GetByIdAsync(query.WorkingHourId); if (workingHour == null) { throw new ApiException($"Working Hour Not Found."); } return(new Response <WorkingHour>(workingHour)); }
public async Task <Response <int> > Handle(DeleteWorkingHourByIdCommand command, CancellationToken cancellationToken) { var workingHour = await _workingHourRepository.GetByIdAsync(command.WorkingHourById); if (workingHour == null) { throw new ApiException($"Working Hour Not Found."); } await _workingHourRepository.DeleteAsync(workingHour); return(new Response <int>(workingHour.WorkingHourId)); }
public async Task <Response <int> > Handle(UpdateWorkingHourCommand command, CancellationToken cancellationToken) { var workingHour = await _workingHourRepository.GetByIdAsync(command.WorkingHourId); if (workingHour == null) { throw new ApiException($"Working Hour Not Found."); } else { workingHour.WorkingHourId = command.WorkingHourId; workingHour.WorkingHourDuration = command.WorkingHourDuration; await _workingHourRepository.UpdateAsync(workingHour); return(new Response <int>(workingHour.WorkingHourId)); } }