public ActionResult Edit(Category category) { if (ModelState.IsValid) { category.ParentId = (category.ParentId == null) ? 0 : category.ParentId; category.CreateDate = DateTime.Now; category.Alias = ConvertToAlias.ConvertTitle(category.CategoryName); db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind(Include = "CategoryId,CategoryName,Alias,Description,Order,status,ParentId,CreateDate")] Category category) { if (ModelState.IsValid) { category.ParentId = (category.ParentId == null) ? 0 : category.ParentId; category.CreateDate = DateTime.Now; category.Alias = ConvertToAlias.ConvertTitle(category.CategoryName); db.Category.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }