public async Task <ActionResult <CatalogItem> > ItemByIdAsync(int id) { if (id <= 0) { return(BadRequest()); } CatalogItem item = null; if (!_settings.EFCoreCachingEnabled) { item = await _catalogContext.CatalogItems.SingleOrDefaultAsync(ci => ci.Id == id); } else { var options = new CachingOptions { }; options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.NCacheAbsoluteExpirationTime)); item = await _catalogContext.CatalogItems.DeferredSingleOrDefault(ci => ci.Id == id).FromCacheAsync(options); } var baseUri = _settings.PicBaseUrl; item.FillProductUrl(baseUri); if (item != null) { return(item); } return(NotFound()); }