Exemplo n.º 1
0
        public ActionResult AjaxOrders()
        {
            var obj               = _ordersApi.OrderByBedIdContactId(UserItem.AgencyID, ArrId.FirstOrDefault());
            var packetId          = Request["packetId"] ?? "0";
            var lstProductDefault = _ordersApi.ProductDefaultbyBedid(UserItem.AgencyID, ArrId.FirstOrDefault(), int.Parse(packetId));
            var model             = new ModelOrderGetItem
            {
                ID                    = obj.ID,
                UserName              = UserItem.UserName,
                CustomerName          = obj.CustomerName,
                Mobile                = obj.Mobile,
                Address               = obj.Address,
                AgencyID              = UserItem.AgencyID,
                StartDate             = obj.StartDate,
                ProductID             = obj.ProductID,
                IsEarly               = lstProductDefault.IsEarly,
                Listproduct           = obj.Listproduct,
                LstProductPacketItems = lstProductDefault.ListProductPacketItems,
                TimeEarly             = lstProductDefault.TimeEarly,
                TimeWait              = lstProductDefault.TimeWait,
                ListItem              = obj.ListItem,
                DiscountItems         = _discountAPI.GetDiscountItem(1, UserItem.AgencyID)
            };

            if (obj.Listproduct != null && obj.Listproduct.Any())
            {
                model.Time  = 0;
                model.Price = obj.Listproduct.Sum(c => c.Shop_Product.Shop_Product_Detail.Price * (decimal)c.Shop_Product.Product_Size.Value / 1000);
            }
            else if (lstProductDefault.ListProductPacketItems != null && lstProductDefault.ListProductPacketItems.Any())
            {
                model.Time  = lstProductDefault.ListProductPacketItems.Sum(c => c.Time);
                model.Price = lstProductDefault.ListProductPacketItems.Sum(c => c.Price);
            }
            else
            {
                model.Time  = 0;
                model.Price = 0;
            }
            return(View(model));
        }