public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Address).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressExists(Address.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(ContactEmail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactEmailExists(ContactEmail.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index", new { id = ContactEmail.ContactID })); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Contact = await _context.Contact.FindAsync(id); if (Contact != null) { //Delete numbers var numbers = _context.ContactNumber.Where(n => n.ContactID == Contact.ID); foreach (var nr in numbers) { _context.ContactNumber.Remove(nr); } //Delete emails var emails = _context.ContactEmail.Where(e => e.ContactID == Contact.ID); foreach (var email in emails) { _context.ContactEmail.Remove(email); } //Delete Contact _context.Contact.Remove(Contact); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Address.Add(Address); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int id) { if (!ModelState.IsValid) { return(Page()); } ContactNumber.ContactID = id; _context.ContactNumber.Add(ContactNumber); await _context.SaveChangesAsync(); return(RedirectToPage("./Index", new { id })); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Address = await _context.Address.FindAsync(id); if (Address != null) { _context.Address.Remove(Address); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ContactNumber = await _context.ContactNumber.FindAsync(id); int cID = ContactNumber.ContactID; if (ContactNumber != null) { _context.ContactNumber.Remove(ContactNumber); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index", new { id = cID })); }