Esempio n. 1
0
 public async Task SeedAsync(UserIdentityContext context, ILogger <UserIdentityContextSeed> logger)
 {
     var policy = CreatePolicy(logger, nameof(UserIdentityContextSeed));
     await policy.ExecuteAsync(async() =>
     {
         if (!context.Plans.Any())
         {
             await context.Plans.AddRangeAsync(GetPreconfiguredPlans());
             await context.SaveChangesAsync();
         }
     });
 }
Esempio n. 2
0
        public async Task <UserEntity> AddUser(UserEntity newUser)
        {
            var emailAddressExist = await _identityContext.Users.AnyAsync((user) => user.Email == newUser.Email);

            if (emailAddressExist)
            {
                throw new RegisterDomainException($"User with {newUser.Email} address already exists");
            }
            _identityContext.Users.Add(newUser);
            await _identityContext.SaveChangesAsync();

            return(newUser);
        }