/// <summary> /// Funkcja do wczytywania kategorii i ich linków. Zmienia kodowanie. /// </summary> private void GetCategories() { var listTitles = new List <string>(); var listUrls = new List <string>(); WebClient webClient = new WebClient(); Encoding enc = Encoding.GetEncoding("ISO-8859-2"); webClient.Encoding = enc; string page = webClient.DownloadString(ResourceRss.UrlWebsite); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(page); var titles = from node in doc.DocumentNode.SelectNodes("//td[@class = 'tdPolecane01']") select node.InnerText.ToString(); listTitles = titles.AsQueryable().ToList(); var urls = from node in doc.DocumentNode.SelectNodes("//td[@class = 'tdPolecane02']") select node.InnerText.ToString(); listUrls = urls.AsQueryable().ToList(); for (int i = 0; i < listTitles.Count(); i++) { ListCategories.Add(new Category { Name = listTitles[i], Url = listUrls[i] }); } }
/// <summary> /// Recharge les Categories de prix depuis la DB /// </summary> public void LoadCategories() { List <CategoryPrice> categoryPrices = CategoryPriceServices.GetAllPrice(); ListCategories.Clear(); foreach (CategoryPrice categoryPrice in categoryPrices) { ListCategories.Add(categoryPrice); } }