public async Task NegativeProductQuantity_AddEntity_ThrowException()
        {
            var customer = new Customer();
            var order    = new Order
            {
                OrderDetails = new List <OrderDetail>
                {
                    new OrderDetail {
                        Quantity = -1
                    }
                }
            };

            var exception = await Assert.ThrowsAsync <ProblemDetailsException>(() =>
                                                                               _customerService.AddEntity(customer, order));

            Assert.Equal(StatusCodes.Status400BadRequest, exception.Details.Status);
            Assert.Contains("product", exception.Details.Title, StringComparison.OrdinalIgnoreCase);
        }
        public async Task <ActionResult <OrderResponseModel> > AddCustomerOrder(int customerId,
                                                                                OrderRequestModel orderRequestModel)
        {
            var customer = await DoesCustomerExist(customerId);

            var order = _mapper.Map <Order>(orderRequestModel);
            await _customerService.AddEntity(customer, order);

            if (await _customerService.IsSavedToDb())
            {
                var persistedOrderModel = _mapper.Map <OrderResponseModel>(order);
                return(CreatedAtAction(nameof(GetCustomerOrder),
                                       new { customerId, orderId = order.OrderId },
                                       persistedOrderModel));
            }

            return(BadRequest());
        }