Exemple #1
0
        public ActionResult <OrderDTO> Confirm(
            [FromServices] IFeeModel feeModel,
            OrderDTO orderDTO)
        {
            if (DataHelper.IsEmptyString(orderDTO.OrderItems))
            {
                return(BadRequest());
            }
            //Parse list order Item
            var orderDetailDTOs = DataHelper.ParserJsonTo <List <OrderDetailDTO> >(orderDTO.OrderItems);
            var pramOrder       = _orderModel.GetPramOrder(orderDetailDTOs);
            //
            double promBill   = 0;
            double promMethod = 0;
            // double promPoint = 0;
            int point = 0;
            //bills
            var bills = _promModel.GetListDTOsPromBill();

            if (bills != null || bills?.Count > 0)
            {
                promBill = _orderModel.FindPromBill(pramOrder.Item2, pramOrder.Item1, bills);
            }
            //point
            // var points = _promModel.GetListDTOsPromPoint();
            // if (points != null || points?.Count > 0)
            // {
            //     if (orderDTO.PointUse != 0)
            //         promPoint = _orderModel.FindPromPoint((int)orderDTO.PointUse, points);
            //     point = _orderModel.GetdPoint(pramOrder.Item2, points);
            // }
            //Get point
            var fees = feeModel.GetListDTOs();

            if (fees != null || fees.Count > 0)
            {
                orderDTO.Fees = DataHelper.ParserObjToJson(fees);
            }
            orderDTO.Point     = point;
            orderDTO.Promotion = DataHelper.ParserObjToJson(new
            {
                bill      = promBill,
                methodPay = promMethod,
                // promPoint = promPoint
            });
            return(orderDTO);
        }