コード例 #1
0
        public IActionResult AddNinja(Ninja ninja)
        {
            ninjaFactory = new NinjaFactory();
            TryValidateModel(ninja);
            ViewBag.Error = ModelState;
            ninjaFactory.AddNinja(ninja);

            return(RedirectToAction("Ninjas"));
        }
コード例 #2
0
 public IActionResult AddNinja(Ninja newninja)
 {
     TryValidateModel(newninja);
     if (ModelState.IsValid)
     {
         ninjaFactory.AddNinja(newninja);
     }
     return(Redirect("ninja"));
 }
コード例 #3
0
 public IActionResult RegisterNinja(Ninja newNinja)
 {
     if (ModelState.IsValid)
     {
         ninjaFactory.AddNinja(newNinja);
         return(RedirectToAction("Success"));
     }
     return(View("Index", newNinja));
 }
コード例 #4
0
        public IActionResult Create(NinjaIndex model)
        {
            Ninja ninja = model.NewNinja;

            if (ModelState.IsValid)
            {
                _ninjaFactory.AddNinja(ninja);
                return(RedirectToAction("Index"));
            }
            return(View("Index", new NinjaIndex()
            {
                Ninjas = _ninjaFactory.AllNinjas(),
                Dojos = _dojoFactory.AllDojos(),
                NewNinja = ninja
            }));
        }