public ActionResult Edit(SubCategory_model cat) { SubCategory tblcat = db.SubCategories.Where(x => x.SubcategoryID == cat.SubCategoryID).Single <SubCategory>(); tblcat.CategoryID = cat.CategoryID; tblcat.SubcategoryID = cat.SubCategoryID; tblcat.SubcategoryDescription = cat.SubCategoryDescription; tblcat.SubcategoryName = cat.SubCategoryName; db.SubmitChanges(); return(View()); }
public ActionResult Edit(int id) { SubCategory_model cat = db.SubCategories.Where(x => x.SubcategoryID == id).Select(x => new SubCategory_model() { CategoryID = x.CategoryID, SubCategoryID = x.SubcategoryID, SubCategoryName = x.SubcategoryName, SubCategoryDescription = x.SubcategoryDescription }).SingleOrDefault(); return(View(cat)); }
public ActionResult SubCategory(SubCategory_model cat) { SubCategory tblcat = new SubCategory(); tblcat.SubcategoryName = cat.SubCategoryName; tblcat.SubcategoryDescription = cat.SubCategoryDescription; tblcat.CategoryID = cat.CategoryID; db.SubCategories.InsertOnSubmit(tblcat); db.SubmitChanges(); ViewBag.cat = new SelectList(db.MasterCategories, "CategoryID", "CategoryName"); return(View()); }