Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        public async Task ClearCallsHistory(string method, string clientId)
        {
            var all = await _tableStorage.GetDataAsync(ApiCallHistoryRecord.GeneratePartitionKey(method, clientId));

            await _tableStorage.DeleteAsync(all);
        }
Exemplo n.º 3
0
        public async Task <int> GetCallsCount(string method, string clientId)
        {
            var all = await _tableStorage.GetDataAsync(ApiCallHistoryRecord.GeneratePartitionKey(method, clientId));

            return(all.Count());
        }
Exemplo n.º 4
0
        public Task InsertRecordAsync(string method, string clientId)
        {
            var entity = ApiCallHistoryRecord.Create(method, clientId);

            return(_tableStorage.InsertAndGenerateRowKeyAsDateTimeAsync(entity, entity.DateTime));
        }