public async Task <Platform.SearchResult> SearchAsync(Platform.SearchModel model, CancellationToken cancellationToken = default) { var cacheKey = _cacheHelper.CreateKey <Platform.SearchModel, Platform.SearchResult>(model); if (TryGetFromCache(cacheKey, out Platform.SearchResult result)) { return(result); } using var process = GetProcess <ISearchPlatform>(); process.Model = model; return(TrySaveToCache(cacheKey, await process.ExecuteAsync(cancellationToken), _configuration.CacheExpiration.Platform.Search)); }
public async Task ExecuteAsync(Platform.SearchModel model, Platform.SearchResult result, SqlConnection connection, CancellationToken cancellationToken = default) { using var command = Get(model, connection); using var reader = await command.ExecuteReaderAsync(cancellationToken); if (reader.HasRows) { while (await reader.ReadAsync(cancellationToken)) { result.Platforms.Add(_readerConverter.Convert(reader)); } } result.TotalCount = await ReadTotalCountAsync(reader, cancellationToken); }
private SqlCommand Get(Platform.SearchModel model, SqlConnection connection) => connection.CreateProcedureCommand(PROCEDURE) .AddPaginationParameters(model) .AddInParameter(PARAM_FILTERTEXT, model.FilterText) .AddIntListParameter(PARAM_SKIPPEDIDS, model.SkippedIds);
public Task <Platform.SearchResult> SearchAsync(Platform.SearchModel model, CancellationToken cancellationToken = default) { using var process = GetProcess <ISearchPlatform>(); process.Model = model; return(process.ExecuteAsync(cancellationToken)); }