Esempio n. 1
0
        public async Task <IActionResult> Method(RegisterHamsterModel regHamster)
        {
            ViewBag.Errors = new List <string>();
            if (ModelState.IsValid)
            {
                System.Console.WriteLine("HAMSTER MODEL IS VALID");
                System.Console.WriteLine("HAMSTER MODEL IS VALID");
                System.Console.WriteLine("HAMSTER MODEL IS VALID");
                System.Console.WriteLine("HAMSTER MODEL IS VALID");
                ECommerce.Models.Hamster newHammy = new ECommerce.Models.Hamster {
                    HamsterFirstName = regHamster.HamsterFirstName,
                    HamsterLastName  = regHamster.HamsterLastName,
                    HamsterEmail     = regHamster.HamsterEmail,
                };
                IdentityResult hammyResult = await _hammyManager.CreateAsync(newHammy, regHamster.HamsterPassword);

                if (hammyResult.Succeeded)
                {
                    System.Console.WriteLine("HAMSTER IS SUCCEEDEEEDDIIINNG");
                    System.Console.WriteLine("HAMSTER IS SUCCEEDEEEDDIIINNG");
                    System.Console.WriteLine("HAMSTER IS SUCCEEDEEEDDIIINNG");
                    System.Console.WriteLine("HAMSTER IS SUCCEEDEEEDDIIINNG");
                    System.Console.WriteLine("HAMSTER IS SUCCEEDEEEDDIIINNG");
                    await _hammysignInManager.SignInAsync(newHammy, isPersistent : false);
                }
                foreach (var error in hammyResult.Errors)
                {
                    System.Console.WriteLine("Errors FOund");
                    ModelState.AddModelError(string.Empty, error.Description);
                }
                _waterFeeder.Add(newHammy);
                _waterFeeder.SaveChanges();
                return(RedirectToAction("RegistrationHome"));
            }
            ViewBag.Errors = ModelState.Values;
            return(View("RegistrationHome"));
        }
Esempio n. 2
0
 public HammyBlog()
 {
     Hamster = new Hamster();
 }