public async Task <IActionResult> Edit(int id, [Bind("customerId,customerfname,customerlname,customerphone")] Customer customer) { if (id != customer.customerId) { return(NotFound()); } if (customer.Validate(customer.customerfname, customer.customerlname, customer.customerphone) == false) { return(View("Fail")); } else { if (ModelState.IsValid) { try { _context.Update(customer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PatientExists(customer.customerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customer)); } }
public async Task <IActionResult> Edit(int id, [Bind("showId,showType,showDate,cinemaId,customerId")] Show show) { if (id != show.showId) { return(NotFound()); } if (show.Validate(show.showType) == false) { return(View("Fail")); } else { if (ModelState.IsValid) { try { _context.Update(show); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppointmentExists(show.showId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } //set the alias of doctor ID and patient ID to the full name of the doctor or patient so the user can see who the ID belongs too ViewData["cinemaId"] = new SelectList(_context.cinema, "cinemaId", "fullname", show.cinemaId); ViewData["customerId"] = new SelectList(_context.customer, "customerId", "customerfullname", show.customerId); return(View(show)); } }