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> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } PackageAppointment = await _context.PackageAppointment .Include(p => p.Beautician) .Include(p => p.Customer) .Include(p => p.CustomerPackage).FirstOrDefaultAsync(m => m.ID == id); if (PackageAppointment == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } PackageAppointment = await _context.PackageAppointment .Include(p => p.Beautician) .Include(p => p.Customer) .Include(p => p.CustomerPackage).FirstOrDefaultAsync(m => m.ID == id); if (PackageAppointment == null) { return(NotFound()); } ViewData["BeauticianID"] = new SelectList(_context.Beautician, "ID", "Name"); ViewData["CustomerID"] = new SelectList(_context.Customer, "ID", "Name"); ViewData["PackageID"] = new SelectList(_context.Packages, "ID", "PackageName"); return(Page()); }