예제 #1
0
        public ActionResult GetOrderDetail(int id, bool isContactOrder)
        {
            var response = new ContactOrderItem();

            if (isContactOrder)
            {
                response = _dl.getDetailById(id);
                var list = _dl.GetListDetailsById(id);
                response.LstOrderDetailItems = list;
            }
            else
            {
                var shopOrder = _ordersDa.GetItemById(id);

                response.TotalPrice  = shopOrder.TotalPrice;
                response.Status      = shopOrder.Status;
                response.ReceiveDate = shopOrder.ReceiveDate ?? 0;
                response.AgencyId    = shopOrder.AgencyId;
                response.CutomerID   = shopOrder.CustomerID;
                response.ID          = shopOrder.ID;

                var lst = new OrderDetailDA().GetList(id);
                var tmp = new List <OrderDetailItem>();

                foreach (var item in lst)
                {
                    tmp.Add(new OrderDetailItem()
                    {
                        ProductName = item.ProductName,
                        UrlImg      = item.UrlImg,
                        Quantity    = item.Quantity,
                        TotalPrice  = item.TotalPrice,
                        Weight      = item.Weight,
                        Price       = item.Price
                    });
                }

                response.LstOrderDetailItems = tmp;
            }

            if (response.AgencyId != AgencyId)
            {
                return(Json(new JsonMessage(true, "'")));
            }

            //get customer info
            if (response.CutomerID != null)
            {
                var customerDa = new CustomerDA();
                response.CustomerItem = customerDa.GetCustomerItem(response.CutomerID.Value);
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }