public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { List <string> shortLanguage = new List <string>(); var getGenre = await GenericRestRequest <string[]> .GetDataAsync(RequestUrlProperties.GetTranslations); var getGenreList = getGenre.ToList(); getGenreList.ForEach(g => { shortLanguage.Add(g.Substring(g.IndexOf('-') + 1).ToLower()); }); output.TagName = "div"; foreach (string genre in shortLanguage.Distinct().OrderBy(a => a)) { TagBuilder a = new TagBuilder("a"); a.InnerHtml.Append(genre); a.Attributes.Add("class", "btn navbar-button-language my-2"); TagBuilder span = new TagBuilder("span"); span.Attributes["class"] = $"flag-icon flag-icon-{genre}"; a.InnerHtml.AppendHtml(span); output.Content.AppendHtml(a); IUrlHelper urlHelper = _urlHelperFactory.GetUrlHelper(ViewContextData); a.Attributes.Add("href", urlHelper.Action("ChangeLanguage", "Home", new { language = genre, returnUrl = urlHelper.Action(ViewContextData.RouteData.Values["action"].ToString(), ViewContextData.RouteData.Values["controller"].ToString()) })); //add disable button when language content is empty //add nice View //add actual language in outside } }
public async Task <IViewComponentResult> InvokeAsync(string request) { var getImage = await GenericRestRequest <GetPopular> .GetDataAsync(request); var results = getImage.Results; return(View("Carousel", results)); }
public async Task <IViewComponentResult> InvokeAsync(string request) { var getTopRated = await GenericRestRequest <GetTopRated> .GetDataAsync(request); // UrlRequest Domyslnie z pliku Resx ale jak pusty to bezposrednio ze stringa (zmienic plik resx na liste?) var results = getTopRated.Results; ViewBag.TotalPages = getTopRated.TotalPages; return(View("Zone", results)); }
public async Task <IViewComponentResult> InvokeAsync(string[] request) { var getGenre = await GenericRestRequest <GetGenres> .GetDataAsync(request[0]); var getImages = await GenericRestRequest <GetPopular> .GetDataAsync(request[1]);// powinno byc GetResult zamiast GetPopular aby uniknac redundaancji kodu; nalezy umiescic interface; for (int genre = 0; genre < getGenre.Genres.Count(); genre++) { getGenre.Genres[genre].Image = getImages.Results[genre].Backdrop_path; } var results = getGenre.Genres.OrderBy(g => g.Name).ToList(); return(View("Slider", results)); }