Esempio n. 1
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    Customer customer = new Customer()
                    {
                        UserId = user.Id,
                        FirstName = model.FirstName,
                        LastName = model.LastName,
                        BankBranchId = model.BankBranchId
                    };

                    _customerRepository.Add(customer);

                    await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);                 

                    return RedirectToAction("Profile", "Index");
                }

                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            model.BankBranches = _bankBranchRepository.GetAllBankBranches().Select(s => new SelectListItem { Text = s.Name, Value = s.Id.ToString() });
            model.BankBranchId = 1;
            return View(model);
        }
Esempio n. 2
0
 public ActionResult Register()
 {
     RegisterViewModel registerModel = new RegisterViewModel();
     registerModel.BankBranches = _bankBranchRepository.GetAllBankBranches().Select(s => new SelectListItem { Text = s.Name, Value = s.Id.ToString()});
     registerModel.BankBranchId = 1;
     return View(registerModel);
 }