public async Task <IRealizeOrderPropositionResponse> RealizeOrderProposition(IRealizeOrderPropositionRequest request) { try { IGetOrderPropositionByIdRequest getOrderPropositionByIdRequest = new GetOrderPropositionByIdRequest(request.OrderPropositionId); IGetOrderPropositionResponse getOrderPropositionResponse = await _orderPropositionsProvider.GetOrderPropositionById(getOrderPropositionByIdRequest); if (getOrderPropositionResponse.Result == OrderPropositionsProvideResultEnum.Exception || getOrderPropositionResponse.Result == OrderPropositionsProvideResultEnum.Forbidden) { return(new RealizeOrderPropositionResponse(RealizeOrderPropositionResult.Exception)); } if (getOrderPropositionResponse.Result == OrderPropositionsProvideResultEnum.NotFound) { return(new RealizeOrderPropositionResponse(RealizeOrderPropositionResult.NotFound)); } OrderProposition orderProposition = getOrderPropositionResponse.OrderProposition; if (request.UserId != orderProposition.CreatorID) { return(new RealizeOrderPropositionResponse(RealizeOrderPropositionResult.Forbidden)); } ICreateOrderResponse createOrderResponse = await _orderCreator.CreateOrder(new CreateOrderRequest(request.OrderPropositionId)); return(createOrderResponse.Result switch { CreateOrderResult.Success => new RealizeOrderPropositionResponse(createOrderResponse.Order), CreateOrderResult.Exception => new RealizeOrderPropositionResponse(RealizeOrderPropositionResult.Exception), CreateOrderResult.CreatedNotFound => new RealizeOrderPropositionResponse(RealizeOrderPropositionResult.Exception), _ => throw new ArgumentOutOfRangeException() }); }
public IActionResult CustomerForm(CustomerDataViewModel model) { if (!model.NeedDelivery) { ModelState["DeliveryInfo.Adress"].ValidationState = ModelValidationState.Skipped; } if (ModelState.IsValid) { _orderCreator.SetCustomer(model); _orderCreator.CreateOrder(_dbContext); return(RedirectToAction("SuccessOrder")); } CustomerDataVMInitializer(model); return(View(model)); }