public async Task <IActionResult> Create([Bind("customerId,customerfname,customerlname,customerphone")] Customer customer) { //check if the user input is valid through a function and put input in database if it is valid else show fail screen if (customer.Validate(customer.customerfname, customer.customerlname, customer.customerphone) == false) { return(View("Fail")); } else { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customer)); } }
public async Task <IActionResult> Create([Bind("showId,showType,showDate,showname,cinemaId,customerId")] Show show) { //put the appointment type into a validate function to check its string length if (show.Validate(show.showType) == false) { return(View("Fail")); } else { if (ModelState.IsValid) { _context.Add(show); await _context.SaveChangesAsync(); 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)); } }