public ActionResult Edit([Bind(Include = "ID,UserName,Password,Active")] User user) { if (ModelState.IsValid && user.UserName.ToLower() != "admin") { string encodedPassword = TextEncoding.EncodeString(user.Password); user.Password = encodedPassword; _db.Entry(user).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Edit([Bind(Include = "Id,UserId,RoleId")] UserRole user_Roles) { if (ModelState.IsValid) { _db.Entry(user_Roles).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RoleId = new SelectList(_db.Roles, "ID", "Roles", user_Roles.RoleId); ViewBag.UserId = new SelectList(_db.Users, "ID", "UserName", user_Roles.UserId); return(View(user_Roles)); }