//Описание продукта public ActionResult Item(Guid id) { //Шаблон ViewName = _Repository.GetModuleView(ControllerName, ActionName); if (string.IsNullOrEmpty(ViewName)) { throw new Exception("Не указан шаблон представления для данного контроллера и метода"); } var model = new ProductFrontModel() { LayoutInfo = _layoutData, Breadcrumbs = _breadcrumb, PageName = _pageName, User = CurrentUser }; var userId = CurrentUser.UserId; model.Item = _Repository.GetProduct(id); model.InCart = _Repository.GetCartItemsIdList(userId); return(View(ViewName, model)); }
public ActionResult Index() { //web.Areas.Admin.Models.VMProductGroupModel grouplist = new web.Areas.Admin.Models.VMProductGroupModel(); //grouplist.ProductGroup = ProductManager.GetProductGroupList("tr"); // ViewBag.ProductGroup = ProductManager.GetProductGroupItem(pId); int pId = 0; int cId = 0; if (RouteData.Values["id"] != null) { pId = Convert.ToInt32(RouteData.Values["id"]); } if (RouteData.Values["cid"] != null) { cId = Convert.ToInt32(RouteData.Values["cid"]); } ViewData["referanslar"] = ReferenceManager.GetReferenceListForFront(lang); using (MainContext db = new MainContext()) { Product prodak = new Product(); if (cId != 0) { prodak = ProductManager.GetProductGroupbyId(cId); } else { prodak = ProductManager.GetProductById(pId); } ViewData["prodak"] = prodak; List <Product> prodakprds; if (prodak == null) { prodakprds = ProductManager.GetProductByTopProductGroupId(cId); ViewData["prodak"] = new Product { Name = SharedRess.SharedStrings.m_urunler }; } else { prodakprds = ProductManager.GetProductByTopProductGroupId(prodak.TopProductGroupId); } List <ProductFrontModel> productsmodel = new List <ProductFrontModel>(); foreach (var item in prodakprds) { ProductFrontModel model = new ProductFrontModel(); model.product = ProductManager.GetProductById(item.ProductId); int catId = model.product.ProductGroupId; model.headers = db.ProductHeaders.FirstOrDefault(x => x.CategoryId == catId); model.ProductInfo = db.ProductInformation.Where(x => x.ProductId == item.ProductId).ToList(); model.Colors = db.ProductColors.Where(x => x.ProductId == item.ProductId).ToList(); ViewBag.ProductGroup = model.product.ProductGroup.GroupName; //ViewBag.Photos = PhotoManager.GetListForFront(11, pId); model.photos = PhotoManager.GetListForFront(11, item.ProductId); //ViewBag.ProductInfo = db.ProductDetail.Where(x => x.ProductId == pId).ToList(); productsmodel.Add(model); } var prodakprdtip = db.ProductGroup.Where(d => d.TopProductId == 1 && d.Language == lang && d.Deleted == false && d.Online == true).ToList(); ViewData["productgroups"] = prodakprdtip; ViewBag.cid = cId; ViewBag.id = pId; return(View(productsmodel)); } }