public void ChangeOrderPaymentType(ChangeOrderPaymentTypeRequestDto changeOrderPaymentTypeRequestModel) { var recievedTime = DateTime.Now; var orderId = changeOrderPaymentTypeRequestModel.OrderId; var newPaymentType = changeOrderPaymentTypeRequestModel.NewPaymentType; _logger.LogInformation($"Смена типа оплаты заказа: { orderId } на { newPaymentType }" + $" на стороне приложения в { changeOrderPaymentTypeRequestModel.ActionTime } пользователем {HttpContext.User.Identity?.Name ?? "Unknown"}"); var user = _userManager.GetUserAsync(User).Result; var driver = _employeeData.GetByAPILogin(user.UserName); var resultMessage = "OK"; try { _actionTimeHelper.ThrowIfNotValid(recievedTime, changeOrderPaymentTypeRequestModel.ActionTime); IEnumerable <PaymentDtoType> availableTypesToChange = _aPIOrderData.GetAvailableToChangePaymentTypes(orderId); if (!availableTypesToChange.Contains(newPaymentType)) { var errorMessage = $"Попытка сменить тип оплаты у заказа { orderId } на недоступный для этого заказа тип оплаты { newPaymentType }"; _logger.LogWarning(errorMessage); throw new ArgumentOutOfRangeException(nameof(changeOrderPaymentTypeRequestModel.NewPaymentType), errorMessage); } Vodovoz.Domain.Client.PaymentType newVodovozPaymentType; if (newPaymentType == PaymentDtoType.Terminal) { newVodovozPaymentType = Vodovoz.Domain.Client.PaymentType.Terminal; } else if (newPaymentType == PaymentDtoType.Cash) { newVodovozPaymentType = Vodovoz.Domain.Client.PaymentType.cash; } else { var errorMessage = $"Попытка сменить тип оплаты у заказа { orderId } на не поддерживаемый для смены тип оплаты { newPaymentType }"; _logger.LogWarning(errorMessage); throw new ArgumentOutOfRangeException(nameof(changeOrderPaymentTypeRequestModel.NewPaymentType), errorMessage); } _aPIOrderData.ChangeOrderPaymentType(orderId, newVodovozPaymentType, driver); } catch (Exception ex) { resultMessage = ex.Message; throw; } finally { _driverMobileAppActionRecordModel.RegisterAction(driver, DriverMobileAppActionType.ChangeOrderPaymentTypeClicked, changeOrderPaymentTypeRequestModel.ActionTime, recievedTime, resultMessage); } }