public ActionResult ProductDetails(string id, string category) { using (var context = new ShopContainer()) { ShopViewModel model = new ShopViewModel(context, category, null, null, id, null, null, null); this.SetSeoContent(model); ViewBag.MainMenu = model.MainMenu; return View(model); } }
public ActionResult Tags(string id, int? page, string order, string direction) { using (var context = new ShopContainer()) { ShopViewModel model = new ShopViewModel(context, null, null, id, null, page, order, direction); this.SetSeoContent(model); ViewBag.MainMenu = model.MainMenu; ViewBag.TotalCount = model.TotalProductsCount; ViewBag.Page = page ?? 0; ViewBag.ActionId = id; ViewBag.ActionName = "Tags"; return View("Products", model); } }
public ActionResult Search(string q, int? page) { using (var context = new ShopContainer()) { ShopViewModel model = new ShopViewModel(context, null, null, null, null, null, null, null, false, q); this.SetSeoContent(model); ViewBag.MainMenu = model.MainMenu; ViewBag.TotalCount = model.TotalProductsCount; ViewBag.Page = page ?? 0; ViewBag.ActionId = ""; ViewBag.ActionName = "Search"; if (!string.IsNullOrEmpty(q)) { var query = q.Trim().ToLower(); if (!string.IsNullOrEmpty(query)) { var products = context.Product.Include("Category").Include("ProductImages") //.Where(p => p.Title.Contains(query)) .ToList(); products = products.Where(p => p.Category.Title.ToLower().Contains(query)||p.Title.ToLower().Contains(query)).ToList(); if (products.Count == 0) { ViewBag.Message = "Ничего не найдено"; } else { model.Products.AddRange(products); } } } return View("Products", model); } }