public CreateNewOrderResponse CreateNewOrder(CreateNewOrderRequest Request) { var Response = new CreateNewOrderResponse(); try { var CurrentOrder = _unitOfWork.RepositoryFactory <Order>().Insert( new Order { DateTime = DateTime.Now }); foreach (var item in Request.AllMeals) { _unitOfWork.RepositoryFactory <Order_Meals>().Insert( new Order_Meals { IsCombo = item.IsCombo, IsSpicy = item.IsSpicy, Meal_Id = item.Meal_Id, Q = item.Q, Order_Id = CurrentOrder.Id }); } _unitOfWork.Save(); Response.SetBaseResponse(true, 0, ""); } catch (Exception ex) { Response.SetBaseResponse(false, 0, ex.Message); } return(Response); throw new NotImplementedException(); }
public async Task ProcessOrderAsync([QueueTrigger("%NewOrdersQueue%")] CreateNewOrderRequest request) { try { // // TODO: Do some additional processing. // await _shippingService.ShipNewOrderAsync(new ShipNewOrderRequest()); } catch (Exception exception) { _logger.LogError(exception, "Error when processing the new order."); } }
internal async Task <CreateNewOrderResponse> CreateOrder(CreateNewOrderRequest request) { if (request == null) { throw new Exception("No data provided to API"); } var anyQueryString = (request.AutoSubmitForFulfillment || request.UpdateExisting) ? "?" : string.Empty; var confirmString = request.AutoSubmitForFulfillment ? "confirm=1" : string.Empty; var updateExistingString = request.UpdateExisting ? "update_existing=1" : string.Empty; var joinerString = (request.AutoSubmitForFulfillment && request.UpdateExisting) ? "&" : string.Empty; var apiResponse = await _client.PostAsync <CreateNewOrderResponse, OrderInput>( $"orders{anyQueryString}{confirmString}{joinerString}{updateExistingString}", request.OrderData); return(apiResponse); }
public async Task <Result> HandleAsync(CreateNewOrderRequest request, IAsyncCollector <CreateNewOrderRequest> newOrders) { try { var validationResult = _validator.Validate(request); if (!validationResult.IsValid) { return(Result.Failure(ErrorCodes.ValidationError, validationResult.Errors.Select(x => x.ErrorMessage).ToArray())); } await newOrders.AddAsync(request); return(Result.Success()); } catch (Exception exception) { _logger.LogError(exception, "Error occured when processing the new order."); } return(Result.Failure(ErrorCodes.NewOrder, "Error occured when processing the new order.")); }
public void CreateOrder(CreateNewOrderRequest order) { AddMessageToQueue(order); }
public bool CreateNewOrder(CreateNewOrderRequest Request) { OrderService _OrderService = new OrderService(); return((bool)_OrderService.CreateNewOrder(Request).isSuccess); }
public async Task <CreateNewOrderResponse> CreateOrder(CreateNewOrderRequest request) { var result = await _orderService.CreateOrder(request); return(result); }
public async Task <IActionResult> CreateNewOrder([FromBody] CreateNewOrderRequest createNewOrderRequest) { await _mediator.Send(new CreateNewOrderCommand(createNewOrderRequest.OrderName)); return(Ok()); }