public ActionResult Delete(int Id) { using (var db = new cmvcEntities()) { var oUser = db.user.Find(Id); //1 active //2 inactive //3 deleted oUser.idState = 3; db.Entry(oUser).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(Content("1")); }
public ActionResult Edit(EditUserViewModel model) { if (!ModelState.IsValid) { return(View(model)); } using (var db = new cmvcEntities()) { var oUser = db.user.Find(model.Id); oUser.email = model.Email; oUser.edad = model.Edad; if (model.Password != null && model.Password.Trim() != "") { oUser.password = model.Password; } db.Entry(oUser).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(Redirect(Url.Content("~/User/"))); }