public void ScrapeDataOfVote(string page) { var web = new HtmlWeb(); var doc = web.Load("https://www.sejm.gov.pl/sejm9.nsf/" + page); var votingDatePage = doc.DocumentNode.SelectNodes(".//tbody/tr"); foreach (var votingPage in votingDatePage) { var name = HttpUtility.HtmlDecode(votingPage.SelectSingleNode(".//td[2]").InnerText); var vote = HttpUtility.HtmlDecode(votingPage.SelectSingleNode(".//td[3]").InnerText); VotingList.Add(new Voting() { Name = name, Vote = vote }); HtmlNode node = votingPage.SelectSingleNode(".//td[5]"); if (node != null) { var name2 = HttpUtility.HtmlDecode(votingPage.SelectSingleNode(".//td[5]").InnerText); var vote2 = HttpUtility.HtmlDecode(votingPage.SelectSingleNode(".//td[6]").InnerText); VotingList.Add(new Voting() { Name = name2, Vote = vote2 }); } } }
public VotingList InfoForRaitingList(int?groupId, string userId) { var Group = db.Groups.Where(n => n.GroupId == groupId).ToList(); var listS = new List <int>(); foreach (var s in Group) { foreach (var st in s.TeachersSubjects) { listS.Add(st.Id); } } var query = from listTeacher in db.Teachers from listRaiting in db.Ratings from listSubject in db.Subjects from listTeachersSubject in db.TeacherSubject .Where(listTeachersSubj => (listS.Contains(listTeachersSubj.Id) && listSubject.Id == listTeachersSubj.SubjectId && listTeacher.TeacherId == listTeachersSubj.TeacherId && listRaiting.TeacherId == listTeacher.TeacherId)) orderby listRaiting.AvgRating descending select new ListOfTeachers() { TeacherId = listTeacher.TeacherId, Name = listTeacher.Name, SurName = listTeacher.SurName, LastName = listTeacher.LastName, PathToPhoto = listTeacher.PathToPhoto, Description = listTeacher.Description, AvgRating = listRaiting.AvgRating, IdForVoiting = listTeachersSubject.Id, SubjectName = listSubject.Name }; //---------------------------------// //-----------------------------------// var data = new VotingList { Info = query.ToList() }; return(data); }