private async Task AddFailedLoginAttempts(int requestsCount) { for (var i = 0; i < requestsCount; i++) { var failedAttempt = new FailedAttemptEntity { PartitionKey = TestConstants.FakeIpAddress, RowKey = DateTimeOffset.Now.Ticks.ToString() }; await _fixtureTable.ExecuteAsync(TableOperation.Insert(failedAttempt)); } }
public async Task PersistFailedAttemptAsync(FailedAttempt failedAttempt) { var failedAttemptToPersist = new FailedAttemptEntity { PartitionKey = failedAttempt.IpAddress, RowKey = failedAttempt.FailedAt.Ticks.ToString() }; var command = _storageCommand.AddCommand(failedAttemptToPersist); try { await _storageClient.ExecuteCommandAsync(command); } catch (StorageException exception) when(exception.RequestInformation.HttpStatusCode == 409) { throw new FailedAttemptConflictException("Record already exists in the table.", exception); } }