public ActionResult Create([Bind(Include = "SubcategoryID,PropertyID")] SubcategoryPropertyViewModel subcategoryProperty, int subcatId) { if (ModelState.IsValid) { subcategoryProperty.SubcategoryID = subcatId; _subcatPropService.Add(subcategoryProperty); return(RedirectToAction("Index", new { id = subcategoryProperty.SubcategoryID })); } ViewBag.PropertyID = new SelectList(_propertyService.GetAll(), "PropertyID", "Name", subcategoryProperty.PropertyID); ViewBag.SubcategoryID = new SelectList(_subcategoryService.GetAll(), "SubcategoryID", "Name", subcategoryProperty.SubcategoryID); return(View(subcategoryProperty)); }
public ActionResult Create(int productId) { ViewBag.ProductID = productId; int subcatId = _productService.GetById(productId).SubcategoryID; ViewBag.SubcategoryID = new SelectList(_subcategoryService.GetAll().Where(s => s.SubcategoryID == subcatId), "SubcategoryID", "Name"); var curSubcatProperties = _subcatPropService.GetAll().Where(p => p.SubcategoryID == subcatId); var properties = _propertyService.GetAll(); var curProdProperties = from Subcategory_property in curSubcatProperties join property in properties on Subcategory_property.PropertyID equals property.PropertyID select new { PropertyID = Subcategory_property.PropertyID, Name = property.Name }; ViewBag.PropertyID = new SelectList(curProdProperties.AsEnumerable(), "PropertyID", "Name"); return(View()); }
// GET: Subcategories /// <summary> /// Insex returns list with subcategories where CategoryID = id /// </summary> /// <param name="id">Category ID</param> /// <returns></returns> public ActionResult Index(int id) { ViewBag.CategoryId = id; return(View(_subcategoryService.GetAll().ToList().Where(s => s.CategoryID == id))); }
public IList <Subcategory> GetAll() { return(subcategoryService.GetAll()); }