Exemplo n.º 1
0
        public async Task <ActionResult> Store(string username, string password)
        {
            var account = new Account()
            {
                UserName  = username,
                Email     = username,
                FirstName = "Xuan Hung",
                LastName  = "Dao",
                Avatar    = "avatar",
                Birthday  = DateTime.Now,
                CreatedAt = DateTime.Now
            };
            IdentityResult result = await _userManager.CreateAsync(account, password);

            if (result.Succeeded)
            {
                _userManager.AddToRole(account.Id, "User");

                // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link
                string code = await _userManager.GenerateEmailConfirmationTokenAsync(account.Id);

                await _userManager.SendEmailAsync(account.Id, "Hello world! Please confirm your account", "<b>Please confirm your account</b> by clicking <a href=\"http://google.com.vn\">here</a>");

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

            return(View("Register"));
        }