public ActionResult Edit([Bind(Include = "CategoryId,Name")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit( [Bind(Include = "CategoryId,Name,DepartmentId,CreatedBy,DateCreated")] Category category) { var loggedinuser = Session["courseshuffleloggedinuser"] as AppUser; if (ModelState.IsValid) { if ((loggedinuser != null) && (loggedinuser.Role == UserType.Administrator.ToString())) { category.DateLastModified = DateTime.Now; category.LastModifiedBy = loggedinuser.AppUserId; db.Entry(category).State = EntityState.Modified; db.SaveChanges(); TempData["category"] = "The category has been modified!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Index")); } TempData["category"] = "Your session has expired,Login Again!"; TempData["notificationtype"] = NotificationType.Info.ToString(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Name", category.DepartmentId); return(View(category)); }