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 ActionResult Nuevo(TablaViewModel model) { try { if (ModelState.IsValid) { using (DemoWebEntities db = new DemoWebEntities()) { var oTabla = new Tabla(); oTabla.Nombre = model.Nombre; oTabla.Categoria = model.Categoria; oTabla.Fecha_Alta = model.Fecha_Alta; db.Tabla.Add(oTabla); db.SaveChanges(); } return(Redirect("~/Tabla/")); } return(View(model)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public dynamic Add(dynamic postData) { var UserName = (string)postData.Name; var Password = (string)postData.Password; var user = new User() { UserName = UserName, Password = Password, IsActive = true }; db.Users.Add(user); var rowCount = db.SaveChanges(); return(rowCount); }
public ActionResult Eliminar(int Id) { using (DemoWebEntities db = new DemoWebEntities()) { var oTabla = db.Tabla.Find(Id); db.Tabla.Remove(oTabla); db.SaveChanges(); } return(Redirect("~/Tabla/")); }
public dynamic Add(dynamic postData) { var roleName = (string)postData.Name; var roleDesc = (string)postData.Desc; var role = new Role() { Name = roleName, Description = roleDesc, IsActive = true }; db.Roles.Add(role); var rowCount = db.SaveChanges(); return(rowCount); }