public ActionResult BrandPartial(int id, SortedVariants srtVariant = SortedVariants.Default, int page = 1, int countPage = 21) { IEnumerable<t_Product> model = null; ViewBag.srtVariant = srtVariant; ViewBag.Id = id; switch (srtVariant) { case SortedVariants.Default: model = db.ProductsRepository.GetAll().Where(i => i.BrandID == id); break; case SortedVariants.NameByAsc: model = db.ProductsRepository.GetAll().Where(i => i.BrandID == id).OrderBy(i => i.ProductName); break; case SortedVariants.NameByDesc: model = db.ProductsRepository.GetAll().Where(i => i.BrandID == id).OrderByDescending(i => i.ProductName); break; case SortedVariants.PriceByAsc: model = db.ProductsRepository.GetAll().Where(i => i.BrandID == id).OrderBy(i => i.Price); break; case SortedVariants.PriceByDesc: model = db.ProductsRepository.GetAll().Where(i => i.BrandID == id).OrderByDescending(i => i.Price); break; default: model = db.ProductsRepository.GetAll().Where(i => i.BrandID == id); break; } return PartialView(new PagerList<t_Product>(model, page, countPage)); }
public ActionResult SearchPartial(string querySearch, SortedVariants srtVariant = SortedVariants.Default, int page = 1, int countPage = 21) { IEnumerable<t_Product> model = null; ViewBag.srtVariant = srtVariant; ViewBag.Query= querySearch; if (querySearch != null) { model = db.ProductsRepository.GetAll() .Where( w => w.ProductName.ToUpper().Contains(querySearch.ToUpper()) || (w.Description != null && w.Description.ToUpper().Contains(querySearch.ToUpper()))); switch (srtVariant) { case SortedVariants.Default: break; case SortedVariants.NameByAsc: model = model.OrderBy(i => i.ProductName); break; case SortedVariants.NameByDesc: model = model.OrderByDescending(i => i.ProductName); break; case SortedVariants.PriceByAsc: model = model.OrderBy(i => i.Price); break; case SortedVariants.PriceByDesc: model = model.OrderByDescending(i => i.Price); break; default: break; } } return PartialView("SearchPartial", new PagerList<t_Product>(model, page, countPage)); }
public ActionResult CategoryPartial(int id, SortedVariants srtVariant = SortedVariants.Default, int page = 1, int countPage = 21, CategoryFilterService filter = null) { IEnumerable<t_Product> result = null; IEnumerable<t_Product> model = null; t_Category categoryTree = null; ViewBag.srtVariant = srtVariant; ViewBag.Id = id; model = GenerateProductList(id); switch (srtVariant) { case SortedVariants.Default: result = model; break; case SortedVariants.NameByAsc: result = model.OrderBy(i => i.ProductName); break; case SortedVariants.NameByDesc: result = model.OrderByDescending(i => i.ProductName); break; case SortedVariants.PriceByAsc: result = model.OrderBy(i => i.Price); break; case SortedVariants.PriceByDesc: result = model.OrderByDescending(i => i.Price); break; default: result = model; break; } return PartialView(new PagerList<t_Product>(result, page, countPage)); }
public SortedListModel(string name, SortedVariants sortedVariants) { Name = name; SortedVariants = sortedVariants; }