public async Task <IActionResult> Create(Student p) { if (ModelState.IsValid) { await StudentDb.Add(p, context); return(RedirectToAction("Index")); } //Show web page with errors return(View(p)); }
public IActionResult Create(Student p) { if (ModelState.IsValid) { StudentDb.Add(p, context); ViewData["Message"] = $"{p.Name} was added!"; return(View()); } //Show web page with errors return(View(p)); }
public IActionResult Create(Student stu) { if (ModelState.IsValid) { StudentDb.Add(stu, context); ViewData["Message"] = $"{stu.Name} was added!"; return(RedirectToAction(nameof(Index))); } //Show web page with errors return(View(stu)); }
public async Task <IActionResult> Create(Student p) { if (ModelState.IsValid) { await StudentDb.Add(p, context); ViewData["Message"] = $"{p.Name} was added!"; return(RedirectToAction("Index")); } //Show web page with errors return(View(p)); }
public IActionResult Create(Student s) { if (ModelState.IsValid) { //Add the student to the DB StudentDb.Add(s, context); TempData["Message"] = $"{s.Name} was added!"; //Redirects the user to the students page //after a student is added return(RedirectToAction("Students")); } //Show web page with errors return(View(s)); }