public async Task TestCreateOrderAsync() { // Arrange var logger = LoggingHelper.GetLogger <SalesController>(); var service = ServiceMocker.GetSalesService(nameof(TestCreateOrderAsync)); var controller = new SalesController(logger, service); var model = new OrderHeaderRequest { CustomerID = 1, PaymentMethodID = new Guid("7671A4F7-A735-4CB7-AAB4-CF47AE20171D"), Comments = "Order from unit tests", CreationUser = "******", CreationDateTime = DateTime.Now, Details = new List <OrderDetailRequest> { new OrderDetailRequest { ProductID = 1, ProductName = "The King of Fighters XIV", Quantity = 1, } } }; // Act var response = await controller.CreateOrderAsync(model) as ObjectResult; var value = response.Value as ISingleResponse <OrderHeader>; service.Dispose(); // Assert Assert.False(value.DidError); Assert.True(value.Model.OrderHeaderID.HasValue); }
public async Task <IActionResult> CreateOrderAsync([FromBody] OrderHeaderRequest request) { Logger?.LogDebug("{0} has been invoked", nameof(CreateOrderAsync)); // Get response from business logic var response = await SalesService.CreateOrderAsync(request.GetOrder(), request.GetOrderDetails().ToArray()); // Return as http response return(response.ToHttpResponse()); }