Exemplo n.º 1
0
        public ActionResult BuyingHistoryPartial()
        {
            if (Session["LogedUserID"] == null)
            {
                return RedirectToAction("Login", "User");
            }
            int Id_User = int.Parse((Session["LogedUserID"]).ToString());
            List<Order> lstOrder = db.Orders.Where(n => n.Id_User == Id_User).ToList();
            List<DiscInBuyingHistory> lstDiscInBH = new List<DiscInBuyingHistory>();
            if(lstOrder.Count == 0)
            {
                ViewBag.Null = "Bạn chưa mua hàng nên không có lịch sử.";
                return PartialView();
            }

            foreach(var item in lstOrder)
            {
                List<Detail_Order> lstDetailOrder = db.Detail_Order.Where(n => n.Id_Order == item.Id).ToList();
                foreach(var item2 in lstDetailOrder)
                {
                    DiscInBuyingHistory discInBH = new DiscInBuyingHistory((int)item2.Id_Disc, (DateTime)item.Date, (int)item.Status);
                    discInBH.Number = (int)item2.Quantity;
                    lstDiscInBH.Add(discInBH);
                }
            }

            return PartialView(lstDiscInBH);
        }
Exemplo n.º 2
0
 public List<DiscInBuyingHistory> GetDiscUnpaidBills()
 {
     int Id_User = int.Parse((Session["LogedUserID"]).ToString());
     List<Order> lstOrder = db.Orders.Where(n => n.Id_User == Id_User && n.IsPaid == 0).ToList();
     List<DiscInBuyingHistory> lstDiscInBH = new List<DiscInBuyingHistory>();
     List<Direct_Payment_Method> lstDPM = new List<Direct_Payment_Method>();
     foreach (var item in lstOrder)
     {
         List<Detail_Order> lstDetailOrder = db.Detail_Order.Where(n => n.Id_Order == item.Id).ToList();
         foreach (var item2 in lstDetailOrder)
         {
             DiscInBuyingHistory discInBH = new DiscInBuyingHistory((int)item2.Id_Disc, (DateTime)item.Date, (int)item.Status);
             discInBH.Number = (int)item2.Quantity;
             discInBH.Id_Order = (int)item.Id;
             lstDiscInBH.Add(discInBH);
         }
         Direct_Payment_Method DPM = db.Direct_Payment_Method.SingleOrDefault(n => n.Id_Order == item.Id);
         lstDPM.Add(DPM);
     }
     ViewData["lstOrder"] = lstOrder;
     ViewData["lstDPM"] = lstDPM;
     return lstDiscInBH;
 }