public IActionResult Execute([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req, ILogger log) { try { var mapKey = req.Query["key"].FirstOrDefault()?.ToLower(); var pointsOfInterest = _locations.Where(x => x.RawKey().StartsWith(mapKey + "::")).ToList(); var hotness = new Hotness(); var highlights = new List <Highlight>(); foreach (var poi in pointsOfInterest) { var location = _locations.Single(x => x.Key == poi.Key); var totalAvailableSeats = location.Capacity; var filledSeats = _capacityService.NumberOfDesksOccupiedForLocation(poi.RawKey()); filledSeats = filledSeats > totalAvailableSeats ? totalAvailableSeats : filledSeats; var percentage = (int)Math.Floor((double)filledSeats / (double)totalAvailableSeats * 100); var colorGrade = hotness.Rank(percentage); highlights.Add(new Highlight(poi.ImageLocation, colorGrade)); } var outputBytes = _generator.HighlightMap(mapKey, highlights); return(new FileContentResult(outputBytes, "image/jpeg")); } catch (Exception ex) { log.LogError(ex.ToString()); throw; } }