public async Task <ActionResult> GetAllMovies([FromQuery] QueryPagenationParameters pageParameters) { var movies = await _repository.GetAllMovies(); if (movies == null || movies.Count == 0) { string message = _localizer["controllers.movie.error.no_movies_found"]; return(ResponseGenerator.NotFoundResult(message)); } var array = new JArray(); foreach (var movie in movies) { array.Add(movie.ToJsonToken()); } var jObject = new JObject { { "number_movies", movies.Count }, { "movies", array } }; Console.WriteLine("Returning List of " + movies.Count + " movies"); return(ResponseGenerator.OkResult(jObject)); }
public async Task <ActionResult> GetById(long id) { // var isExist = _memoryCache.TryGetValue(CacheMovie + id, out Movie movie); // if (!isExist) // { var movie = await _repository.GetById(id); if (movie == null) { //TODO get message key from resourses string message = _localizer["controllers.movie.error.movie_not_found"]; return(ResponseGenerator.NotFoundResult(message)); } // _memoryCache.Set(CacheMovie + id, movie, TimeSpan.FromHours(6)); // } return(ResponseGenerator.OkResult(movie)); }