Пример #1
0
        public async Task <IUser> CreateUserAsync(string username, bool isAuthorized, CancellationToken cancellationToken = default)
        {
            var user = new PostgresUser
            {
                Id           = this.IdGenerator.Generate(),
                Username     = username,
                AvatarUrl    = null,
                IsAuthorized = isAuthorized
            };

            try
            {
                await this.Database.Users.AddAsync(user, cancellationToken);

                await this.Database.SaveChangesAsync(cancellationToken);

                return(user);
            }
            catch { return(null); }
        }
Пример #2
0
 public PostgresFactory(PostgresDbContext context)
 {
     _users = new PostgresUser(context);
 }