public ActionResult CreateUser(CrudViewModel model) { try { if (ModelState.IsValid) { using (FormEntities1 db = new FormEntities1()) { var oCrud = new TB_Form(); oCrud.nombre = model.Nombre; oCrud.apellido = model.Apellido; oCrud.correo = model.Correo; oCrud.pais = model.Pais; oCrud.telefono = model.Telefono; db.TB_Form.Add(oCrud); db.SaveChanges(); } } return(RedirectToAction("Dashboard")); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Delete(int id) { FormEntities1 db = new FormEntities1(); TB_Form eliminar = db.TB_Form.Where(d => d.id == id).First(); db.TB_Form.Remove(eliminar); db.SaveChanges(); return(RedirectToAction("Dashboard")); }