public ActionResult Index() { DTO_SHOP sto = new DTO_SHOP(); sto.Categoeris = context.Categories.Take(3).ToList(); sto.Products = context.Products.Where(ps => ps.Quantity >= 1).Take(6).ToList(); return(View("Index", sto)); }
public ActionResult Shop(int id) { DTO_SHOP dto = new DTO_SHOP(); var catg = context.Categories.ToList(); var usrprd = context.Products.Where(c => c.CategoryID == id && c.Quantity >= 1).ToList(); dto.Products = usrprd; dto.Categoeris = catg; return(View(dto)); }
public ActionResult Search(string Search) { if (context.Products.Where(ps => ps.Name.Contains(Search)).FirstOrDefault() != null) { DTO_SHOP dto = new DTO_SHOP(); var id = context.Products.Where(ps => ps.Name.Contains(Search) && ps.Quantity >= 1).ToList(); dto.Products = id; dto.Categoeris = context.Categories.ToList(); return(View("Shop", dto)); } else { return(RedirectToAction("Shop")); } }