public ActionResult CreateEmail(Emailx EmailToCreate) { try { _entities.AddToEmail(EmailToCreate); _entities.SaveChanges(); return(RedirectToAction("GetAllEmail")); } catch { return(View()); } }
public ActionResult DeleteEmail(Emailx EmailToDelete) { EmailToDelete = _entities.Email.First(m => m.Id == EmailToDelete.Id); if (!ModelState.IsValid) { return(View(EmailToDelete)); } _entities.DeleteObject(EmailToDelete); _entities.SaveChanges(); return(RedirectToAction("GetAllEmail")); }
public ActionResult EditEmail(Emailx EmailToEdit) { var originalEmail = _entities.Email.First(m => m.Id == EmailToEdit.Id); if (!ModelState.IsValid) { return(View(originalEmail)); } _entities.ApplyCurrentValues(originalEmail.EntityKey.EntitySetName, EmailToEdit); _entities.SaveChanges(); return(RedirectToAction("GetAllEmail")); }
public int SaveEmail(Emailx email) { try { if (email.Id == 0) { _encuestasDbEntities.AddToEmail(email); _encuestasDbEntities.SaveChanges(); return(0); } var originalEmail = _encuestasDbEntities.Email.First(m => m.Id == email.Id); _encuestasDbEntities.ApplyCurrentValues(originalEmail.EntityKey.EntitySetName, email); _encuestasDbEntities.SaveChanges(); return(1); } catch { return(-1); } }