public ActionResult Editar(EditUserViewModel model) { if (!ModelState.IsValid) { return(View(model)); } using (var db = new crudDBEntities()) { User oUser = db.User.Find(model.Id); oUser.name = model.Name; oUser.email = model.Email; oUser.edad = model.Edad; if (model.Password != null && model.Password.Trim() != "") { oUser.password = model.Password; } db.Entry(oUser).State = EntityState.Modified; db.SaveChanges(); } return(Redirect(Url.Content("~/User/Index"))); }
public ActionResult Eliminar2(int Id) { using (var db = new crudDBEntities()) { User oUser = db.User.Find(Id); oUser.idState = 3; db.Entry(oUser).State = EntityState.Modified; db.SaveChanges(); } return(Content("1")); }