Beispiel #1
0
        private async Task <UserEntity> CheckUserAsync(
            string userCode,
            string document,
            string firstName,
            string lastName,
            string email,
            string phone,
            UserType userType,
            string campaignName)
        {
            UserEntity user = await _userHelper.GetUserAsync(email);

            if (user == null)
            {
                user = new UserEntity
                {
                    UserCode    = userCode,
                    FirstName   = firstName,
                    LastName    = lastName,
                    Email       = email,
                    UserName    = email,
                    PhoneNumber = phone,
                    Document    = document,
                    UserType    = userType,
                    LoginType   = LoginType.App
                };

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

                await _userHelper.AddUserToRoleAsync(user, userType.ToString());

                if (campaignName != "Admin")
                {
                    await _userHelper.AddUserToCampaignAsync(user, campaignName);
                }
                string token = await _userHelper.GenerateEmailConfirmationTokenAsync(user);

                await _userHelper.ConfirmEmailAsync(user, token);
            }

            return(user);
        }