Example #1
0
        public ActionResult GetTotalProductConfirm(decimal todayCode)
        {
            //lay so luong da confirm
            var products    = _da.GetTotalProductConfirm(todayCode);//_da.GetTotalProductConfirm(todayCode)
            var supplierids = products.Select(m => m.SupplierId).Distinct().ToList();

            var model = new List <TotalProductToDayConfirmItem>();

            //lay so luong da dat xe
            var orderCars = _orderCarDa.GetByToday(todayCode).GroupBy(m => new { m.ProductId, m.SupplierId });

            var suppliers = _supplierDa.GetList(supplierids = products.Select(m => m.SupplierId).Distinct().ToList());

            foreach (var dnSupplierItem in suppliers)
            {
                var item = new TotalProductToDayConfirmItem()
                {
                    SupplierName    = dnSupplierItem.Name,
                    SupplierPhone   = dnSupplierItem.Mobile,
                    SupplierAddress = dnSupplierItem.Address,
                    SupplierId      = dnSupplierItem.ID,
                    Details         = new List <ProductConfirm>()
                };
                var detal = products.Where(m => m.SupplierId == item.SupplierId).ToList();

                foreach (var productConfirm in detal)
                {
                    var amountActive = _amountProductDa.GetAmount(productConfirm.ProductId, todayCode, dnSupplierItem.ID);
                    if (amountActive != null)
                    {
                        productConfirm.QuantityActive = amountActive.AmountEstimate - amountActive.AmountPayed;
                    }

                    var total = orderCars
                                .FirstOrDefault(m => m.Key.SupplierId == productConfirm.SupplierId &&
                                                m.Key.ProductId == productConfirm.ProductId);
                    if (total != null)
                    {
                        productConfirm.QuantityReady = total.Sum(m => m.Quantity);
                    }
                }

                item.Details.AddRange(detal);
                model.Add(item);
            }

            return(Json(model));
        }
Example #2
0
 public void TestMethod4()
 {
     var da  = new RequestWareDA();
     var lst = da.GetTotalProductConfirm(40780800);
 }