예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
 private SqlCommand Get(Platform.SearchModel model, SqlConnection connection) =>
 connection.CreateProcedureCommand(PROCEDURE)
 .AddPaginationParameters(model)
 .AddInParameter(PARAM_FILTERTEXT, model.FilterText)
 .AddIntListParameter(PARAM_SKIPPEDIDS, model.SkippedIds);
예제 #4
0
 public Task <Platform.SearchResult> SearchAsync(Platform.SearchModel model, CancellationToken cancellationToken = default)
 {
     using var process = GetProcess <ISearchPlatform>();
     process.Model     = model;
     return(process.ExecuteAsync(cancellationToken));
 }