Ejemplo n.º 1
0
        async public Task <object> AjaxSearchAsync(string searchQuery, string page)
        {
            string response = await _client.SearchAsync(searchQuery, page);

            OmdbSearchResult searchResultObject = JsonSerializer.Deserialize <OmdbSearchResult>(response);

            return(new { result = searchResultObject });
        }
Ejemplo n.º 2
0
 public static Movie ConvertToMovie(OmdbSearchResult result)
 {
     return(new Movie
     {
         Title = result.Title,
         Year = GetYear(result.Year),
         ImdbId = result.ImdbId,
         Type = result.Type,
         PosterUrl = result.Poster
     });
 }
Ejemplo n.º 3
0
        async public Task <IActionResult> Search([Bind("SearchQuery")] SearchModel model)
        {
            string response;

            try
            {
                response = await _client.SearchAsync(model.SearchQuery);
            }
            catch (Exception e)
            {
                return(RedirectToAction("GeneralError", "Movie"));
            }

            OmdbSearchResult searchResultObject = JsonSerializer.Deserialize <OmdbSearchResult>(response);

            if (searchResultObject.Response == "False")
            {
                return(RedirectToAction("MovieNotFound", "Movie"));
            }
            model.SearchResult = searchResultObject.Search;
            model.Totals       = searchResultObject.totalResults;
            return(View(model));
        }