Esempio n. 1
0
        public async Task <ActionResult> Signup(LoginViewModel userInfo)
        {
            if (ModelState.IsValid)
            {
                var user = new SimpleStoreUser()
                {
                    UserName = userInfo.Email,
                    Email    = userInfo.Email
                };

                var resultuser = await _usermanager.CreateAsync(user, userInfo.Password);

                if (resultuser.Succeeded)
                {
                    await _usermanager.AddToRoleAsync(user, ConstantsSimpleStore.roleNameCustomer);

                    var sigInResult = await _singinManager.PasswordSignInAsync(
                        userInfo.Email,
                        userInfo.Password,
                        true,
                        false);

                    return(Redirect("/"));
                }
                else
                {
                    ModelState.AddModelError("Password", resultuser.ToString());
                }
            }
            return(View());
        }
        public void SimpleStoreUserTest()
        {
            // Arrange

            // Act
            SimpleStoreUser simpleStoreUser = this.CreateSimpleStoreUser();


            // Assert
        }
        private async Task CreateUser(string emailUser, string passwordUser, string userRole)
        {
            var user = new SimpleStoreUser()
            {
                UserName = emailUser,
                Email    = emailUser
            };

            var resultuser = await _usermanager.CreateAsync(user, passwordUser);

            await _usermanager.AddToRoleAsync(user, userRole);
        }