public IActionResult OnPost(int contactId) { var contact = contactData.Delete(contactId); contactData.Commit(); if (Contact == null) { return(RedirectToPage("./NotFound")); } TempData["Message"] = "The Contact has been succesfully deleted."; return(RedirectToPage("./List")); }
public IActionResult OnPost(int contactId) { var contact = contactData.Delete(contactId); contactData.Commit(); if (contact == null) { return(RedirectToPage("./NotFound")); } TempData["Message"] = $"{contact.Name} deleted"; return(RedirectToPage("./List")); }
public IActionResult OnPost() { if (!ModelState.IsValid) { LoadEnums(); return(Page()); } Contact.DateContacted = TodaysDate; _contactData.Add(Contact); _contactData.Commit(); LoadEnums(); return(Page()); }
public IActionResult OnPost() { if (!ModelState.IsValid) { ContactTypes = htmlHelper.GetEnumSelectList <ContactType>(); return(Page()); } if (Contact.Id > 0) { contactData.Update(Contact); } else { contactData.Add(Contact); } contactData.Commit(); TempData["Message"] = "Contact Saved!"; return(RedirectToPage("./Detail", new { contactId = Contact.Id })); }
public IActionResult OnPost() { if (!ModelState.IsValid) { Nationalities = htmlHelper.GetEnumSelectList <NationalityType>(); return(Page()); } if (contact.Id > 0) { contactData.Update(contact); TempData["Message"] = "Contact has been updated."; } else { contactData.Add(contact); TempData["Message"] = "New Contact has been created."; } contactData.Commit(); return(RedirectToPage("./Detail", new { contactId = contact.Id })); }