/// <summary> /// Завершает рабочую смену. /// </summary> /// <returns>Возвращает информацию о следующей рабочей смене.</returns> public async Task <CourierShiftHistoryPauseResponseDto> PauseAsync(CourierShiftHistoryPauseRequestDto model, int courierId) { var item = await FindCurrentOrNextAsync(courierId); if (item.IsEnded) { throw new AppException(AppMessage.ShiftEnded); } if (await AnyPendingOrActiveOrder(courierId)) { throw new AppException(AppMessage.ClosingUncompletedShift); } item.IsStarted = false; // item.IsPaused = true; item.PauseTime = DateTime.Now; item.PauseReasonId = model.ReasonId; item.PauseDescription = model.Comment; await _dbContext.SaveChangesAsync(); return(new CourierShiftHistoryPauseResponseDto() { PausedAt = item.PauseTime?.Format() }); }
public async Task <IHttpActionResult> Pause(CourierShiftHistoryPauseRequestDto model) { if (ModelState.IsValid == false) { return(Response(AppMessage.InvalidModel)); } try { var pauseResponse = await _courierShiftHistoryService.PauseAsync(model, GetCourierId()); return(Ok(pauseResponse)); } catch (AppException e) { return(Response(e)); } }