/// <inheritdoc />
        public async Task <string> RegisterUserAsync(string login, string password, CancellationToken cancellationToken)
        {
            if (await _dbContext.Users.AnyAsync(user => user.Login == login, cancellationToken))
            {
                return(null);
            }

            var user = NewUser(login, password);
            await _dbContext.Users.AddAsync(user, cancellationToken);

            await _dbContext.SaveChangesAsync(cancellationToken);

            return(await GetJwtTokenAsync(user));
        }
Exemple #2
0
        public async Task AddAsync(T item, CancellationToken cancellationToken)
        {
            await DbContext.AddAsync(item, cancellationToken);

            await DbContext.SaveChangesAsync(cancellationToken);
        }