public async Task <IReadOnlyCollection <ReadingVm> > Handle(ReadingQuery args, CancellationToken cancellationToken) { args.ToDate = args.ToDate.ToEndOfTheDate(); var cacheKey = $"reading-{args.BuildingId}-{args.ObjectId}-{args.DataFieldId}-{args.FromDate}-{args.ToDate}"; var readingsFromCache = await _distributedCache .GetCacheAsync <IReadOnlyCollection <ReadingVm> >(cacheKey); if (readingsFromCache != null) { return(readingsFromCache); } var readingsFromDb = await _readingService .GetReadingsAsync(args); await _distributedCache .SetCacheAsStringAsync(cacheKey, readingsFromDb, 30); return(readingsFromDb); }
public async Task <IActionResult> GetDataAsync([FromQuery] SearchModel searchCriteria) { var result = await _readingService.GetReadingsAsync(searchCriteria); return(Ok(result)); }