public async Task <VsfUser> GetUserByCredentials(string userLogin, string userPassword)
        {
            var user = await _appUserManager.FindAsync(userLogin, userPassword);

            if (user == null || !user.IsApproved)
            {
                return(null);
            }

            return(QuicksilverUserModelMapper.MapToVsfModel(user));
        }
        public async Task <VsfUser> CreateUser(UserCreateModel newUser)
        {
            var appUser = new SiteUser
            {
                Id             = Guid.NewGuid().ToString(),
                Username       = newUser.Customer.Email,
                Email          = newUser.Customer.Email,
                EmailConfirmed = false,
                IsLockedOut    = false,
                IsApproved     = true,
                CreationDate   = DateTime.UtcNow
            };

            var result = await _appUserManager.CreateAsync(appUser, newUser.Password);

            if (!result.Succeeded)
            {
                LogDebugErrors("CreateUser failed", result.Errors);
                return(null);
            }

            var newContact = CustomerContact.CreateInstance();

            newContact.PrimaryKeyId = new PrimaryKeyId(new Guid(appUser.Id));

            /* Before it was email here, this is incorrect as epi server looks for customer contact every time the request is authorized (see BusinessFoundationInitializeModule).
             * In this module epi will look for customercontact bu user Id that is set in principal.Name. SInce we set email here before it was not found and there were concurrency exceptions
             * since when epi does not find a contactCustomer, it tries to create it and save to database in GET METHOD in every async request - WTF!!!*/
            newContact.UserId = "String:" + appUser.Id;
            newContact.AcceptMarketingEmail = false;
            newContact.FirstName            = newUser.Customer.FirstName;
            newContact.LastName             = newUser.Customer.LastName;
            newContact.Email = newUser.Customer.Email;
            newContact.SaveChanges();

            var user = await _appUserManager.FindByIdAsync(appUser.Id);

            return(QuicksilverUserModelMapper.MapToVsfModel(user));
        }
        public async Task <VsfUser> GetUserById(string userId)
        {
            var user = await _appUserManager.FindByIdAsync(userId);

            return(QuicksilverUserModelMapper.MapToVsfModel(user));
        }