//SINAV DETAY SAYFASI public ActionResult DetailExam(string ID) { QuestionsDA qda = new QuestionsDA(); DataModel.QuestionsModel qdm = new DataModel.QuestionsModel(); qdm = qda.DetailExam(Convert.ToInt32(ID)); return(View(qdm)); }
//DOĞRU CEVAP KONTROL public JsonResult ControlReply(string q1, string q2, string q3, string q4, string ID) { QuestionsDA qda = new QuestionsDA(); DataModel.QuestionsModel qdm = new DataModel.QuestionsModel(); qdm = qda.DetailExam(Convert.ToInt32(ID)); return(Json(new { success = true, data = qdm })); //return Json(qdm); }
//MAKALE SERVİS public ActionResult Questions() { Uri url = new Uri("https://www.wired.com/most-recent/"); WebClient client = new WebClient(); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string html = client.DownloadString(url); HtmlAgilityPack.HtmlDocument dokuman = new HtmlAgilityPack.HtmlDocument(); dokuman.LoadHtml(html); HtmlNodeCollection basliklar = dokuman.DocumentNode.SelectNodes("//li[@class='archive-item-component']"); String[] linkler = new string[5]; int i = 0; foreach (var baslik in basliklar) { if (i == 5) { break; } //string ReplaceString = baslik.OuterHtml.Replace("\"", "'"); int LinkBasla = baslik.OuterHtml.IndexOf("href="); int LinkBitir = baslik.OuterHtml.IndexOf("<div class=\"archive-item-component__img\">"); string link = baslik.OuterHtml.Substring(LinkBasla + 7, LinkBitir - LinkBasla - 10); //link = link.Substring(0, link.Length - 34); linkler[i] = link; i++; } List <QuestionsModel> questList = new List <DataModel.QuestionsModel>(); for (int j = 0; j < 5; j++) { Uri NewURL = new Uri("https://www.wired.com/" + linkler[j]); WebClient newClient = new WebClient(); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string NewHtml = newClient.DownloadString(NewURL); HtmlAgilityPack.HtmlDocument NewDokuman = new HtmlAgilityPack.HtmlDocument(); NewDokuman.LoadHtml(NewHtml); HtmlNodeCollection NewBaslik = NewDokuman.DocumentNode.SelectNodes("//h1[@id='articleTitleFull']"); HtmlNodeCollection NewDescription = NewDokuman.DocumentNode.SelectNodes("//p"); /* * ' --> ' * & --> & */ if (NewBaslik != null) { QuestionsModel qq = new DataModel.QuestionsModel(); qq.Topic = NewBaslik.ElementAt(0).InnerHtml.Replace("'", "'"); qq.Topic = qq.Topic.Replace("&", "&"); qq.Ask = NewDescription.ElementAt(0).InnerText; questList.Add(qq); } if (NewBaslik == null) { NewBaslik = NewDokuman.DocumentNode.SelectNodes("//h1[@class='content-header__row content-header__hed']"); if (NewBaslik != null) { QuestionsModel qq = new DataModel.QuestionsModel(); qq.Topic = NewBaslik.ElementAt(0).InnerHtml.Replace("'", "'"); qq.Topic = qq.Topic.Replace("&", "&"); qq.Ask = NewDescription.ElementAt(0).InnerText; questList.Add(qq); } } } ViewData["Liste"] = questList; HttpContext.Session.SetString("Liste", JsonConvert.SerializeObject(questList)); return(View(questList)); }