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)); }
// GET: SubcategoryProperty/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubcategoryPropertyViewModel SubcategoryProperty = _subcatPropService.GetById((int)id); if (SubcategoryProperty == null) { return(HttpNotFound()); } return(View(SubcategoryProperty)); }
// GET: SubcategoryProperty/Edit/5 /// <summary> /// Edit serches for subcategory property with ID=id and allows user to edit it /// </summary> /// <param name="id">ID for entity to edit</param> /// <returns></returns> public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubcategoryPropertyViewModel SubcategoryProperty = _subcatPropService.GetById((int)id); if (SubcategoryProperty == null) { return(HttpNotFound()); } ViewBag.PropertyID = new SelectList(_propertyService.GetAll(), "PropertyID", "Name", SubcategoryProperty.PropertyID); ViewBag.SubcategoryID = new SelectList(_subcategoryService.GetAll(), "SubcategoryID", "Name", SubcategoryProperty.SubcategoryID); return(View(SubcategoryProperty)); }