예제 #1
0
 public IActionResult Create(HogwartsStudent student)
 {
     if (ModelState.IsValid)
     {
         return(View("Info", student));
     }
     else
     {
         return(View("Index"));
     }
 }
 public IActionResult Create(HogwartsStudent student, string name, string dojo, string fav_language, string comment)
 {
     if (ModelState.IsValid)
     {
         // do somethng!  maybe insert into db?  then we will redirect
         HogwartsStudent someUser1 = new HogwartsStudent()
         {
             Name             = name,
             Dojo             = dojo,
             FavoriteLanguage = fav_language,
             Comment          = comment
         };
         return(View("RegisterWizard", someUser1));
     }
     else
     {
         // Oh no!  We need to return a ViewResponse to preserve the ModelState, and the errors it now contains!
         return(View("WizardRegForm"));
     }
 }
        public IActionResult RegisterWizard(string name, string dojo, string fav_language, string comment)
        {
            // process the form...

            HogwartsStudent someUser1 = new HogwartsStudent()
            {
                Name             = name,
                Dojo             = dojo,
                FavoriteLanguage = fav_language,
                Comment          = comment
            };

            Console.WriteLine(name);
            Console.WriteLine(dojo);
            Console.WriteLine(fav_language);
            Console.WriteLine(comment);

            // List<User> viewModel = new List<User>()
            // {
            //     someUser1
            // };

            return(View(someUser1));
        }
 public IActionResult RegisterWizard(HogwartsStudent student)    // updated
 {
     return(RedirectToAction("UserDetail", new HogwartsStudent()));
 }