Ejemplo n.º 1
0
        private async Task <User> CreateUserAsync(AddUserViewMadel model)
        {
            var user = new User
            {
                Address     = model.Address,
                Document    = model.Document,
                FirstName   = model.FirstName,
                LastName    = model.LastName,
                Email       = model.username,
                UserName    = model.username,
                PhoneNumber = model.PhoneNumer
            };

            var result = await _userHelper.AddUserAsync(user, model.Password);

            if (result.Succeeded)
            {
                user = await _userHelper.GetUserByEmailAsync(model.username);

                await _userHelper.AdduserToRoleAsync(user, "Owner");

                return(user);
            }
            return(null);
        }
Ejemplo n.º 2
0
        private async Task <User> CheckUserAsync(
            string document,
            string firstName,
            string lastName,
            string email,
            string phone,
            string address,
            string role)
        {
            var user = await _userHelper.GetUserByEmailAsync(email);

            if (user == null)
            {
                user = new User
                {
                    FirstName   = firstName,
                    LastName    = lastName,
                    Email       = email,
                    UserName    = email,
                    PhoneNumber = phone,
                    Address     = address,
                    Document    = document
                };

                await _userHelper.AddUserAsync(user, "123456");

                await _userHelper.AdduserToRoleAsync(user, role);
            }

            return(user);
        }