Ejemplo n.º 1
0
        // GET: TrangChu
        public ActionResult Index(int?page = 1)
        {
            ViewBag.Trang = page;
            List <DanhMucLoc> dm = new List <DanhMucLoc>();

            dm.Add(new DanhMucLoc()
            {
                Id = 1, Name = "Quần jean", IsChecked = false
            });
            dm.Add(new DanhMucLoc()
            {
                Id = 2, Name = "Quần Short", IsChecked = false
            });
            dm.Add(new DanhMucLoc()
            {
                Id = 3, Name = "Áo sơ mi", IsChecked = false
            });
            dm.Add(new DanhMucLoc()
            {
                Id = 4, Name = "Áo thun", IsChecked = false
            });

            DanhMucLocList dmlist = new DanhMucLocList();

            dmlist.loc     = dm;
            Session["dml"] = dmlist;
            return(View(dmlist));
        }
Ejemplo n.º 2
0
        public ActionResult LocSP(DanhMucLocList dml, FormCollection f)
        {
            int giamin = 0, giamax = 0;

            if (f["giaMin"].ToString() != "")
            {
                giamin = Convert.ToInt32(f["giaMin"].ToString());
            }
            else
            {
                giamin = 0;
            }

            if (f["giaMax"].ToString() != "")
            {
                giamax = Convert.ToInt32(f["giaMax"].ToString());
            }
            else
            {
                giamax = 0;
            }
            List <DanhMucLoc> lstLoc = Session["loc"] as List <DanhMucLoc>;
            List <SANPHAM>    lstSP = new List <SANPHAM>();

            if (lstLoc == null)
            {
                lstLoc         = new List <DanhMucLoc>();
                Session["loc"] = lstLoc;
            }
            foreach (var item in dml.loc)
            {
                if (item.IsChecked)
                {
                    List <LOAISANPHAM> lstLoaiSP = db.LOAISANPHAMs.Where(n => n.TENLSP == item.Name).ToList();
                    if (lstLoaiSP == null)
                    {
                        Response.StatusCode = 404;
                        return(null);
                    }
                    if (lstLoaiSP.Count != 0)
                    {
                        foreach (LOAISANPHAM ls in lstLoaiSP)
                        {
                            List <SANPHAM> lstSP1 = db.SANPHAMs.Where(n => n.MALSP == ls.MALSP).OrderBy(n => n.GIABD).ToList();
                            foreach (SANPHAM s in lstSP1)
                            {
                                lstSP.Add(s);
                            }
                        }
                    }
                }
            }
            if (giamax > 0)
            {
                if (lstSP.Count != 0)
                {
                    lstSP = lstSP.Where(n => n.GIABD >= giamin && n.GIABD <= giamax).OrderBy(n => n.GIABD).ToList();
                }
                else
                {
                    lstSP = db.SANPHAMs.Where(n => n.GIABD >= giamin && n.GIABD <= giamax).OrderBy(n => n.GIABD).ToList();
                }
            }
            Session["SP"] = lstSP;
            return(View(dml));
        }
Ejemplo n.º 3
0
        public PartialViewResult DMLoc()
        {
            DanhMucLocList dml = Session["dml"] as DanhMucLocList;

            return(PartialView(dml));
        }