public async Task <IActionResult> GetAllDemands() { var cacheKey = "GetAllDemands_" + Request.Headers["CustomerGuidKey"]; List <AppDemand> demands = new List <AppDemand>(); logger.LogInformation("Accessing Demands from Elastic Cache"); var encodedDemands = await distributedCache.GetAsync(cacheKey); try { if (encodedDemands == null) { logger.LogInformation("Loading Demands from Repository"); demands = await demandRepo.LoadAllDemands(); if (demands == null) { return(NotFound()); } } demands = await cacheManager.ProcessCache(demands, cacheKey, encodedDemands, configuration, distributedCache); return(Ok(demands)); } catch (Exception excp) { logger.LogError("Error Loading Demands from Repository " + excp.Message); // client call must know stack exception return(BadRequest(excp)); } }