// // GET: /CatalogAdmin/Product/ public ActionResult Index(int id = 0) { var result = new IndexProductPageViewModel(); result.Group = _shopService.GetGroups(); if (id == 0) { result.CurrentID = result.Group.First().Category.First().ID; } else { result.CurrentID = id; } result.Products = _productService.GetProducts(result.CurrentID); return(View(result)); }
public ActionResult BaseProducts(ProductForShopViewModel model, FilterParams filter = null) { if (filter == null) { filter = new FilterParams(); } var shop = _shopService.GetShop(filter.Id); //Verification access if (shop == null || (WebSecurity.CurrentUserId != shop.UserID && !User.IsInRole("Administrator") && !User.IsInRole("Moderator"))) { return(HttpNotFound()); } if (WebSecurity.CurrentUserId == shop.UserID && shop.IsActive == false && !User.IsInRole("Administrator") && !User.IsInRole("Moderator")) { TempData["error"] = "Магазин еще не активирован!"; return(Redirect("/")); } var groups = _shopService.GetGroups().ToList(); var selectedGroup = filter.CategoryId == 0 ? groups.First() : groups.First(q => q.ID == filter.CategoryId); var categories = _shopService.GetCategories(selectedGroup.ID); var selectedCategory = filter.SecondCategoryId == 0 ? categories.First() : categories.First(q => q.ID == filter.SecondCategoryId); var emptyManufacturer = new Manufacturer { ID = 0, Name = "Все" }; var manufacturers = new List <Manufacturer> { emptyManufacturer }; manufacturers.AddRange(_shopService.GetManufacturers(selectedCategory.ID)); Manufacturer selectedManufacturer = emptyManufacturer; if (manufacturers.Count > 1) { selectedManufacturer = filter.ThirdCategoryId == 0 ? manufacturers.First() : manufacturers.First(q => q.ID == filter.ThirdCategoryId); } var shopProducts = _shopService.GetShopProducts(shop.ID); model.Filter = filter; model.Groups = new SelectList(groups, "ID", "Name", selectedGroup); model.Categories = new SelectList(categories, "ID", "Name", selectedCategory); model.Manufacturers = new SelectList(manufacturers, "ID", "Name", selectedManufacturer); model.CurrentCategoryID = selectedCategory.ID; model.Shop = shop; model.MonthlyFee = 0; model.ShopProducts = shopProducts; model.Products = selectedCategory.Product.Where(q => selectedManufacturer.ID == 0 || selectedManufacturer.ID == q.ManufacturerID).ToPagedList(filter.Page, ProjectConfiguration.Get.ProductsOnPageInBasePage); var categories2 = shop.ShopProduct.Select(q => q.Product.Category).Distinct().ToList(); if (categories2.Any()) { model.MonthlyFee = categories2.Sum(x => x.Price); } return(View(model)); }
// // GET: /CatalogAdmin/Group/ public ActionResult Index() { return(View(_shopService.GetGroups())); }