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"));
     }
 }
Example #2
0
        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));
        }
Example #3
0
 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"));
 }