public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } PackageAppointment = await _context.PackageAppointment.FindAsync(id); PackageAppointment.AppointmentDate = null; PackageAppointment.AppointmentTime = null; PackageAppointment.BeauticianID = null; _context.Attach(PackageAppointment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { } //Old code to delete //if (PackageAppointment != null) //{ // _context.PackageAppointment.Remove(PackageAppointment); // await _context.SaveChangesAsync(); //} return(Redirect("../Customers/Details?id=" + PackageAppointment.CustomerID)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(PackageTreatment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PackageTreatmentExists(PackageTreatment.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(Customer.ID)) { return(NotFound()); } else { throw; } } return(Redirect("../Customers/Details?id=" + Customer.ID)); }