public IActionResult CreateNinja(Ninja ninja) { // Checks to see if submitted information is valid if (ModelState.IsValid) { _ninjaFactory.AddNewNinja(ninja); return(RedirectToAction("Index")); } else { ViewBag.allNinjas = _ninjaFactory.NinjaWithDojos(); return(View("Index")); } }
public IActionResult RegisterNinja(NinjaView model) { if (ModelState.IsValid) { Ninja ninja = new Ninja { name = model.name, level = model.level, dojo_id = model.dojo_id }; ninjaFactory.AddNewNinja(ninja); return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult NinjaCreate(Ninja model) { if (ModelState.IsValid) { Ninja newNinja = new Ninja { Name = model.Name, Level = model.Level, Description = model.Description, dojo_id = model.dojo_id, }; _ninjafactory.AddNewNinja(newNinja); return(RedirectToAction("Ninjas")); } ViewBag.allNinjas = _ninjafactory.GetAllNinjas(); ViewBag.allDojos = _dojofactory.GetAllDojos(); return(View("Ninjas")); }