public ActionResult Create(SubCategory subcategory) { subcategory.CreateDate = DateTime.Now; subcategory.ModifiedDate = DateTime.Now; if (ModelState.IsValid) { subcategory.SubCategoryID = Guid.NewGuid(); db.SubCategories.Add(subcategory); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", subcategory.CategoryID); return View(subcategory); }
public ActionResult Edit(SubCategory subcategory) { if (ModelState.IsValid) { db.Entry(subcategory).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", subcategory.CategoryID); return View(subcategory); }