public async Task <DateTime[]> GetCallHistoryAsync(string method, string clientId, TimeSpan period) { var timeNow = DateTime.UtcNow; var result = await _tableStorage.WhereAsync(ApiCallHistoryRecord.GeneratePartitionKey(method, clientId), timeNow - period, timeNow, ToIntervalOption.IncludeTo, includeTime : true); return(result.Select(x => x.DateTime).ToArray()); }
public async Task ClearCallsHistory(string method, string clientId) { var all = await _tableStorage.GetDataAsync(ApiCallHistoryRecord.GeneratePartitionKey(method, clientId)); await _tableStorage.DeleteAsync(all); }
public async Task <int> GetCallsCount(string method, string clientId) { var all = await _tableStorage.GetDataAsync(ApiCallHistoryRecord.GeneratePartitionKey(method, clientId)); return(all.Count()); }
public Task InsertRecordAsync(string method, string clientId) { var entity = ApiCallHistoryRecord.Create(method, clientId); return(_tableStorage.InsertAndGenerateRowKeyAsDateTimeAsync(entity, entity.DateTime)); }