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 Add(UserViewModel model) { if (!ModelState.IsValid) { return(View(model)); } using (var db = new cmvcEntities()) { user oUser = new user(); oUser.idState = 1; oUser.email = model.Email; oUser.edad = model.Edad; oUser.password = model.Password; db.user.Add(oUser); db.SaveChanges(); } return(Redirect(Url.Content("~/User/"))); }
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/"))); }