public ActionResult Create(FlightPersonnel FlightPersonnel) { //in case of the need to return to Create.cshtml view if (ModelState.IsValid) { //Add staff record to database FlightPersonnel.StaffId = flightpersonnelContext.Add(FlightPersonnel); //Redirect user to FlightSchedule/Index view return(RedirectToAction("Index")); } else { //Input validation fails, return to the Create view //to display error message return(View(FlightPersonnel)); } }
public ActionResult Create(FlightPersonnel flightPersonnel) { //Get country list for drop-down list //in case of the need to return to Create.cshtml view ViewData["VocationList"] = GetVocation(); ViewData["GenderList"] = GetGender(); ViewData["StatusList"] = GetStatus(); if (ModelState.IsValid) { //Add staff record to database flightPersonnel.StaffID = staffContext.Add(flightPersonnel); //Redirect user to Staff/Index view return(RedirectToAction("Index")); } else { //Input validation fails, return to the Create view //to display error message return(View(flightPersonnel)); } }