private async Task PersistFailedAttemptAsync(string ipAddress) { var failedAttempt = new FailedAttempt(ipAddress, DateTimeOffset.Now); try { await _repository.PersistFailedAttemptAsync(failedAttempt); } catch (FailedAttemptConflictException exception) { throw new FailedAttemptExistsException(failedAttempt.IpAddress, failedAttempt.FailedAt, exception); } }
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); } }