public async Task <ActionResult> createOrder(OrderCM model)
        {
            double totalAmount = 0;

            foreach (var item in model.OrderDetailCMs)
            {
                if (item.Quantity <= 0 || item.Quantity > 5)
                {
                    return(BadRequest());
                }
                var product = _productService.GetProduct(item.ProductId);
                if (product == null)
                {
                    return(BadRequest());
                }
                totalAmount += product.CurrentPrice * item.Quantity;
            }
            var user = await _userManager.GetUserAsync(User);

            var order = model.Adapt <Order>();

            order.BuyerId       = user.Id;
            order.TotalAmount   = totalAmount;
            order.CurrentStatus = (int)OrderCurrentStatus.received;
            _orderService.CreateOrder(order);
            foreach (var item in model.OrderDetailCMs)
            {
                var orderDetail = item.Adapt <OrderDetail>();
                orderDetail.OrderId = order.Id;
                _detailService.CreateOrderDetail(orderDetail);
            }
            _orderService.SaveChanges();
            OrderStatus status = new OrderStatus();

            status.OrderId  = order.Id;
            status.StatusId = (int)OrderStatusId.start;
            _statusService.CreateOrderStatus(status);
            _statusService.SaveChanges();
            return(Ok());
        }