public async Task <ActionResult> Details(string movieId) { MovieDetailsDTO movieDetailsDto = null; Movie movie = GetMovieFromCache(movieId); if (!MovieValidator.ValidateMovieId(movieId)) { return(BadRequest("Please enter a valid movieId")); } if (movie == null) { var doc = getWebsiteHtmlDocument(movieId); movieDetailsDto = CreateMovieDetailsDto(movieId, doc); movie = movieDetailsDto.Adapt <Movie>(); await AddToBothCache(movie); } else { if (movie.Source == "Database") { AddToConcurrentCache(movie); } movieDetailsDto = movie.Adapt <MovieDetailsDTO>(); } return(Ok(movieDetailsDto)); }
public ActionResult getMovie(string movieId) { MovieDTO movieDto; if (!MovieValidator.ValidateMovieId(movieId)) { return(BadRequest("Please enter a valid movieId")); } Movie movie = GetMovieFromCache(movieId); if (movie != null) { movieDto = movie.Adapt <MovieDTO>(); } else { var doc = getWebsiteHtmlDocument(movieId); try { movieDto = CreateMovieDto(movieId, doc); } catch (Exception e) { return(NotFound(e.Message)); } } return(Ok(movieDto)); }