public async Task <TUser> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken) { if (normalizedEmail == null) { throw new ArgumentNullException(nameof(normalizedEmail)); } cancellationToken.ThrowIfCancellationRequested(); var search = _context.FromQueryAsync <TUser>(new QueryOperationConfig { IndexName = "NormalizedEmail-DeletedOn-index", KeyExpression = new Expression { ExpressionStatement = "NormalizedEmail = :email AND DeletedOn = :deletedOn", ExpressionAttributeValues = new Dictionary <string, DynamoDBEntry> { { ":email", normalizedEmail }, { ":deletedOn", default(DateTimeOffset).ToString("o") } } }, Limit = 1 }); var users = await search.GetRemainingAsync(cancellationToken); return(users?.FirstOrDefault()); }
public async Task <TCode> FindByUserCodeAsync(string user_code, CancellationToken cancellationToken) { if (user_code == null) { throw new ArgumentNullException(nameof(user_code)); } cancellationToken.ThrowIfCancellationRequested(); var search = _context.FromQueryAsync <TCode>(new QueryOperationConfig { IndexName = "UserCode-index", KeyExpression = new Expression { ExpressionStatement = "UserCode = :user_code", ExpressionAttributeValues = new Dictionary <string, DynamoDBEntry> { { ":user_code", user_code } } }, Limit = 1 }); var codes = await search.GetRemainingAsync(cancellationToken); return(codes.Find(code => code.ExpiresAt > DateTimeOffset.Now)); }
public async Task <TToken[]> FindBySubjectAsync(string subject, CancellationToken cancellationToken) { if (subject == null) { throw new ArgumentNullException(nameof(subject)); } cancellationToken.ThrowIfCancellationRequested(); var search = _context.FromQueryAsync <TToken>(new QueryOperationConfig { IndexName = "Subject-index", KeyExpression = new Expression { ExpressionStatement = "Subject = :subject", ExpressionAttributeValues = new Dictionary <string, DynamoDBEntry> { { ":subject", subject } } }, Limit = 1 }); var tokens = await search.GetRemainingAsync(cancellationToken); return(tokens.ToArray()); }
public async Task <TApplication> FindByClientIdAsync(string identifier, CancellationToken cancellationToken) { if (identifier == null) { throw new ArgumentNullException(nameof(identifier)); } cancellationToken.ThrowIfCancellationRequested(); var search = _context.FromQueryAsync <TApplication>(new QueryOperationConfig { IndexName = "ClientId-DeletedOn-index", KeyExpression = new Expression { ExpressionStatement = "ClientId = :id AND DeletedOn = :deletedOn", ExpressionAttributeValues = new Dictionary <string, DynamoDBEntry> { { ":id", identifier }, { ":deletedOn", default(DateTimeOffset).ToString("o") } } }, Limit = 1 }); var applications = await search.GetRemainingAsync(cancellationToken); return(applications?.FirstOrDefault()); }
public async Task <TAuthorization> FindAsync(string subject, string client, CancellationToken cancellationToken) { if (subject == null) { throw new ArgumentNullException(nameof(subject)); } if (client == null) { throw new ArgumentNullException(nameof(client)); } cancellationToken.ThrowIfCancellationRequested(); var search = _context.FromQueryAsync <TAuthorization>(new QueryOperationConfig { IndexName = "Subject-Application-index", KeyExpression = new Expression { ExpressionStatement = "Subject = :subject AND Application = :application", ExpressionAttributeValues = new Dictionary <string, DynamoDBEntry> { { ":subject", subject }, { ":application", client } } }, Limit = 1 }); var applications = await search.GetRemainingAsync(cancellationToken); return(applications?.FirstOrDefault()); }
public async Task <IEnumerable <Loan> > GetLoansByStatus(LoanStatus status) { return(await _context.FromQueryAsync <Loan>(new QueryOperationConfig() { IndexName = "by_status", Filter = new QueryFilter("status", QueryOperator.Equal, status.ToString()) }, Cfg()) .GetRemainingAsync()); }
/// <inheritdoc/> public async Task <TinkoffExchangeRate> GetLastRateAsync() { var asyncQuery = _dynamoDBContext.FromQueryAsync <TinkoffExchangeRate>(new QueryOperationConfig { Limit = 1, Filter = new QueryFilter(nameof(TinkoffExchangeRate.From), QueryOperator.Equal, "USD"), BackwardSearch = true, }); var items = await asyncQuery.GetNextSetAsync(); return(items.FirstOrDefault()); }
internal async Task <IList <DynamoIdentityRoleUser> > QueryRoleUsers(string normalisedRoleName, string userId, CancellationToken cancellationToken) { if (normalisedRoleName == null && userId == null) { throw new ArgumentNullException(nameof(normalisedRoleName)); } cancellationToken.ThrowIfCancellationRequested(); var expressions = new List <string>(); var index = "UserId-NormalizedRoleName-index"; var values = new Dictionary <string, DynamoDBEntry>(); if (normalisedRoleName != null) { index = "NormalizedRoleName-UserId-index"; expressions.Add("NormalizedRoleName = :normalizedRoleName"); values.Add(":normalizedRoleName", normalisedRoleName); } if (userId != null) { expressions.Add("UserId = :userId"); values.Add(":userId", userId); } var expression = string.Join(" AND ", expressions); var search = _context.FromQueryAsync <DynamoIdentityRoleUser>(new QueryOperationConfig { IndexName = index, KeyExpression = new Expression { ExpressionStatement = expression, ExpressionAttributeValues = values } }); return(await search.GetRemainingAsync(cancellationToken)); }