public ActionResult Editar(TablaViewModel model) { try { if (ModelState.IsValid) { using (DemoWebEntities db = new DemoWebEntities()) { var oTabla = db.Tabla.Find(model.ProgramaId); oTabla.Nombre = model.Nombre; oTabla.Categoria = model.Categoria; oTabla.Fecha_Alta = model.Fecha_Alta; db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(Redirect("~/Tabla/")); } return(View(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public dynamic ResetPassword(dynamic postData) { var returnValue = ""; var username = (string)postData.UserName; var oldPassword = (string)postData.OldPassword; var newPassword = (string)postData.NewPassword; var user = db.Users.Where(x => x.UserName == username && x.Password == oldPassword).FirstOrDefault(); if (user != null) { user.Password = newPassword; db.Entry(user).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); returnValue = "Password Changed Successfully"; } else { returnValue = "Please Try Again."; } return(returnValue); }