Esempio n. 1
0
        public async Task <IActionResult> Get(string name, string address)
        {
            var geolocationResults = await _geolocationService.GetCoordinates(address);

            if (geolocationResults == null || !geolocationResults.Results.Any())
            {
                return(NotFound("Location"));
            }

            var geolocation = geolocationResults.Results.First().Geometry.Location;

            var results = await _ratingsService.GetRatings(name, geolocation.Latitude, geolocation.Longitude);

            if (results == null || !results.Establishments.Any())
            {
                return(NotFound("Establishment"));
            }

            return
                (Ok(new List <RatingsVm>(
                        results.Establishments.Select(
                            e =>
                            new RatingsVm
            {
                BusinessName = e.BusinessName,
                BusinessPostCode = e.PostCode,
                Rating = e.RatingValue,
                RatingDate = e.RatingDate,
                RatingKey = e.RatingKey,
                HygieneScore = e.Scores?.Hygiene,
                StructuralScore = e.Scores?.Structural,
                ManagementScore = e.Scores?.ConfidenceInManagement
            }))));
        }
Esempio n. 2
0
        public async Task <IEnumerable <Review> > GetReviews(int productId)
        {
            var starsReviewer1 = -1;
            var starsReviewer2 = -1;

            if (await _featureManager.IsEnabledAsync(nameof(FeatureFlags.RatingsEnabled)))
            {
                _logger.LogDebug("RatingsEnabled flag is set to true");
                var ratings = await _ratings.GetRatings(productId);

                starsReviewer1 = ratings.GetValueOrDefault("Reviewer1", -1);
                starsReviewer2 = ratings.GetValueOrDefault("Reviewer2", -1);
            }

            return(new List <Review>
            {
                new Review
                {
                    Reviewer = "Reviewer1",
                    Text = "An extremely entertaining play by Shakespeare. The slapstick humour is refreshing!",
                    Rating = starsReviewer1
                },
                new Review
                {
                    Reviewer = "Reviewer2",
                    Text = "Absolutely fun and entertaining. The play lacks thematic depth when compared to other plays by Shakespeare.",
                    Rating = starsReviewer2
                }
            });
        }