public async Task <IActionResult> Details(Guid id)
        {
            if (!_cacheService.TryGetValue(Constants.CacheKeys.Review + id, out Review review))
            {
                var response = await _httpService.GetAsync($"api/review/{id}");

                if (!response.IsSuccessStatusCode)
                {
                    _flashMessage.Danger("An error occurred on the server.");
                    return(RedirectToAction(nameof(GetAllReviews)));
                }

                review = await _httpService.DeserializeAsync <Review>(response);

                _cacheService.Set(Constants.CacheKeys.Review + id, review);
            }
            return(View(review));
        }
Esempio n. 2
0
        public async Task <IActionResult> Details(string imdbId)
        {
            var response = await _httpService.GetAsync($"api/movie/{imdbId}");

            Movie movie;

            if (!response.IsSuccessStatusCode)
            {
                movie = null;

                if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    _flashMessage.Warning("Movie Not Found");
                    return(View(movie));
                }

                _flashMessage.Danger("An error occurred on the server.");
                return(View(movie));
            }
            _cacheService.Remove(Constants.CacheKeys.AllMovies);
            movie = await _httpService.DeserializeAsync <Movie>(response);

            return(View(movie));
        }