public IActionResult Create(CreateExamDTO Exam) { var a = RSSHelper.GetSubjects("https://www.wired.com/feed/rss"); int examID = _examService.Add(new Entity.Exam { Header = a.Where(x => x.Description == Exam.Description).FirstOrDefault().Title, MemberID = HttpContext.Session.GetObjectFromJson <Member>("Member").ID, Description = Exam.Description }); foreach (var item in Exam.Question) { int quesID = _questionOfExamService.Add( new QuestionOfExam { ExamID = examID, Question = item.Question } ); for (int i = 0; i < 4; i++) { _optionsOfQuestionService.Add(new OptionsOfQuestion { Option = item.Options[i].Option, QuestionOfExamID = quesID, IsCorrect = ((Convert.ToInt32(item.Answer) - 65) == i) ? true : false }); } foreach (var item2 in item.Options) { } } return(RedirectToAction("Index", "Member")); }
/// <summary> /// Initialize View Model and components /// </summary> /// <returns></returns> private async Task UIInitializer() { string exMessage = ""; try { Articles = await RSSHelper.GetArticleListFromFeedAsync(this.FeedUrlString); } catch (Exception e) { exMessage = e.Message; } if (!string.IsNullOrWhiteSpace(exMessage)) { ShowList = false; IsLoading = false; await MessageHelper.ShowMessageAsync(exMessage, "Houston, tenemos un problema!"); App.Current.Exit(); } else { ShowList = true; } FirstOrDefaultArticle = Articles.FirstOrDefault(); IsLoading = false; }
public ActionResult Search(String SupplierId = "", int CategoryId = 0, String Keywords = "") { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); if (SupplierId != "") { var model = db.Products .Where(p => p.SupplierId == SupplierId); return(View(model)); } else if (CategoryId != 0) { var model = db.Products .Where(p => p.CategoryId == CategoryId); return(View(model)); } else if (Keywords != "") { var model = db.Products .Where(p => p.Name.Contains(Keywords)); return(View(model)); } return(View(db.Products)); }
public ActionResult Reset() { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); return(View()); }
public static void createEntry() { var databaseIP = ConfigurationManager.AppSettings["databaseIP"]; if (databaseIP == null) { throw new Exception("No key called 'databaseIP' in App.config *(make sure it's in the right one)*"); } if (!RSSHelper.isConnectedToTheInternet()) { } var ping = new Ping().Send("However we get this"); if (ping.Status != IPStatus.Success) { } using (var context = new PlanningContext()) { if (!context.Database.Exists()) { } } }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); Session.Remove("guid"); // AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); if (ModelState.IsValid) { var user = await UserManager.FindAsync(model.UserName, model.Password); if (user != null) { await SignInAsync(user, model.RememberMe); // return RedirectToLocal(returnUrl); return(View("VerifyPhone")); } else { ModelState.AddModelError("", "Invalid username or password."); } } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> ConfirmPhone(InputModel model) { string ur = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(ur); var client = new HttpClient(); // Add authentication header var AuthyAPIKey = "E09FjK58eXC4oLAovzH9VBxFGzcAlobB"; client.DefaultRequestHeaders.Add("X-Authy-API-Key", AuthyAPIKey); var phone_number = model.PhoneNumber; var country_code = model.DialingCode; var verification_code = model.VerificationCode; var url = $"https://api.authy.com/protected/json/phones/verification/check?" + "&phone_number=" + phone_number + "&country_code=" + country_code + "&verification_code=" + verification_code; HttpResponseMessage response = await client.GetAsync(url); if (response.IsSuccessStatusCode) { return(RedirectToAction("Index", "Home")); } else { return(View(model)); } }
public void UpdateShow(ShowControl sc) { Console.WriteLine("Updating RSS for " + sc.Title); if (sc.LocalFiles) { lock (_shows) { sc.ScanLocalFilesOnly(); } } else { XmlReader RSSFeed = sc.UpdateRSSFile(); if (RSSFeed == null) { Console.WriteLine("Failed to download rss feed"); sc.FailedCount++; return; } try { List <EpisodeControl> episodes = RSSHelper.ReadEpisodes(RSSFeed); lock (_shows) { sc.UpdateEpisode(episodes); } } catch { } } }
public ActionResult Confirm(InputModel model) { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); return(View(model)); }
public IActionResult ExamCreate(ExamDTO exam) { List <Post> postList = RSSHelper.GetAllPost(Url).ToList(); Exam newExam = new Exam(); newExam.Header = postList.Where(a => a.Description == exam.Description).FirstOrDefault().Header; newExam.Description = exam.Description; examService.Insert(newExam); int k = 0; for (int i = 0; i < 4; i++) { Question newQuestion = new Question(); newQuestion.ExamID = newExam.ID; newQuestion.QuestionText = exam.Questions[i].QuestionText; questionService.Insert(newQuestion); for (int j = 0; j < 4; j++) { Option newOption = new Option(); newOption.QuestionID = newQuestion.ID; newOption.OptionText = exam.Options[k].OptionText; newOption.IsCorrect = (j + 65 == exam.Answers[i] ? true : false); optionService.Insert(newOption); k++; } } return(RedirectToAction("Login", "Account")); }
public static List<Event> getEvents(string link) { List<Event> toReturn = new List<Event>(); //http://www.missouririverconf.org/g5-bin/client.cgi?G5genie=167&school_id=6&G5button=13 RSSHelper helper = new RSSHelper(); return parseRSS(helper.parseRSS(link)); }
public ActionResult Register() { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); Session.Remove("guid"); return(View()); }
public ActionResult Contact() { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); ViewBag.Message = "Liên hệ"; return(View()); }
public ActionResult About() { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); ViewBag.Message = "Giới thiệu về Multishop"; return(View()); }
public ActionResult Detail(int id) { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); var order = db.Orders.Find(id); return(View(order)); }
public static List <Event> getEvents(string link) { List <Event> toReturn = new List <Event>(); //http://www.missouririverconf.org/g5-bin/client.cgi?G5genie=167&school_id=6&G5button=13 RSSHelper helper = new RSSHelper(); return(parseRSS(helper.parseRSS(link))); }
// // GET: /Account/LogOff public ActionResult LogOff() { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); AuthenticationManager.SignOut(); Session.Remove("guid"); return(RedirectToAction("Index", "Home")); }
public ActionResult Index() { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); var cart = ShoppingCart.Cart; return(View(cart.Items)); }
public ActionResult List() { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); var orders = db.Orders .Where(o => o.CustomerId == User.Identity.Name); return(View(orders)); }
// GET: Default public ActionResult Index() { string html = @"https://www.ranker.com/list/avengers-trivia-facts/ranker-comics"; var liste = RSSHelper.ReadList(html); ViewBag.List = liste; return(View()); }
public void GetRSS_AllData_ValidRssXml() { MemoryStream ms = new MemoryStream(); Rss rss = GetFullRSS(); RSSHelper.WriteRSS(rss, ms); var result = Encoding.UTF8.GetString(ms.GetBuffer()).Trim('\0'); Assert.AreEqual(GetFullRSSText(), result); }
public ActionResult Index() { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); var model = db.Categories .Where(c => c.Products.Count >= 4) .OrderBy(c => Guid.NewGuid()).ToList(); return(View(model)); }
public void WriteRead_LargeObject_Ok() { MemoryStream ms = new MemoryStream(); Rss rss = GetFullRSS(); RSSHelper.WriteRSS(rss, ms); ms.Position = 0; Rss newRss = RSSHelper.ReadRSS(ms); Assert.AreEqual(rss.Channel.Description, newRss.Channel.Description); }
protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "application/xml"; // 输出并按xml格式显示 MemoryStream ms = new MemoryStream(); Rss rss = GetFullRSS(); RSSHelper.WriteRSS(rss, ms); ms = RSSHelper.RemoveEmptyElement(ms); var result = Encoding.UTF8.GetString(ms.GetBuffer()).Trim('\0'); Response.Write(result); }
public async Task <ActionResult> Manage(ManageUserViewModel model) { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); bool hasPassword = HasPassword(); ViewBag.HasLocalPassword = hasPassword; ViewBag.ReturnUrl = Url.Action("Manage"); if (hasPassword) { if (ModelState.IsValid) { IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword); if (result.Succeeded) { return(RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess })); } else { AddErrors(result); } } } else { // User does not have a password so remove any validation errors caused by a missing OldPassword field ModelState state = ModelState["OldPassword"]; if (state != null) { state.Errors.Clear(); } if (ModelState.IsValid) { IdentityResult result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword); if (result.Succeeded) { return(RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess })); } else { AddErrors(result); } } } // If we got this far, something failed, redisplay form return(View(model)); }
// // GET: /Order/ public ActionResult Checkout() { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); var model = new Order(); model.CustomerId = User.Identity.Name; model.OrderDate = DateTime.Now.Date; model.Amount = ShoppingCart.Cart.Total; return(View(model)); }
// // GET: /Product/ public ActionResult Category(int CategoryID = 0) { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); if (CategoryID != 0) { ViewBag.TieuDe = db.Categories.SingleOrDefault(p => p.Id == CategoryID).Name; var model = db.Products.Where(p => p.CategoryId == CategoryID); return(View(model)); } return(View()); }
public void Read_External_Ok() { MemoryStream ms = new MemoryStream(); var array = Encoding.UTF8.GetBytes(GetPartRSSText()); ms.Write(array, 0, array.Length); ms.Position = 0; Rss rss = RSSHelper.ReadRSS(ms); Assert.AreEqual("channel title", rss.Channel.Title); Assert.AreEqual("long description", rss.Channel.Description); }
// // GET: /Account/Manage public ActionResult Manage(ManageMessageId?message) { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." : message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed." : message == ManageMessageId.Error ? "An error has occurred." : ""; ViewBag.HasLocalPassword = HasPassword(); ViewBag.ReturnUrl = Url.Action("Manage"); return(View()); }
public ActionResult Login(string returnUrl) { string url = "https://vnexpress.net/rss/giai-tri.rss"; ViewBag.listItems = RSSHelper.read(url); if (returnUrl != null) { if (returnUrl.Contains("/Admin/")) { Response.Redirect("/Admin/Account/Login?returnUrl=" + returnUrl); } ViewBag.ReturnUrl = returnUrl; } return(View()); }
public IActionResult Create() { List <SubjectDTO> subjects = RSSHelper.GetSubjects("https://www.wired.com/feed/rss").ToList(); List <SelectListItem> subjectsSelect = new List <SelectListItem>(); foreach (var item in subjects.Take(5)) { subjectsSelect.Add(new SelectListItem { Text = item.Title, Value = item.Description }); } ViewBag.Subject = subjectsSelect; return(View()); }
public static List<Event> parseRSS(RSSHelper.Channel channel) { List<Event> listOFEventsToReturn = new List<Event>(); foreach (var item in channel.Items) { string title = String.Empty; string desc = String.Empty; string Location = string.Empty; string time = String.Empty; Filter fitler = new Filter(); Event events = new Event(); string letsGetInfoFromThis = item.Description; try { title = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(item.Title); title = cleanUpSpaces(title); letsGetInfoFromThis = letsGetInfoFromThis.Replace(item.Title, ""); letsGetInfoFromThis = cleanUpMain(letsGetInfoFromThis); //gets now get the date out letsGetInfoFromThis = removeDate(letsGetInfoFromThis); // Debug.WriteLine("Info: " +letsGetInfoFromThis + ":Title:"+title); string commentSection = getCommentSection(letsGetInfoFromThis); desc = cleanUpSpaces(commentSection); time = getTime(letsGetInfoFromThis).getTimeRangeString(); // Debug.WriteLine("Found time of: " + getTime(letsGetInfoFromThis).getTimeRangeString()); Filter d = getLocation(letsGetInfoFromThis); if (d != null) { //good. we found the location - lets return it now fitler = d; } else if(d == null) { d = GlobalHandlers.DatabaseHandler.getDefaultFilter(); } events.Description = desc; events.From = "0"; events.Filter = d; events.Time = time; events.Title = title; events.Date = DateTime.Now.ToString("MM/dd/yyyy"); Debug.WriteLine("date: " + events.Date); listOFEventsToReturn.Add(events); Debug.WriteLine("Title: " + events.Title + " Desc: " + events.Description + " Filter Name: " + events.Filter.Name + " LongLat: " + events.Filter.Long + "," + events.Filter.Lat + " Time: " + events.Time); //Debug.WriteLine("Rest:" + letsGetInfoFromThis + "Time:" + getTime(letsGetInfoFromThis).getTimeRangeString() + "Title:" + title + "Comments:" + commentSection); } catch (Exception eee) { GlobalHandlers.Debugger.write(eee.ToString()); } // Debug.WriteLine("Title: " +item.Title + ":" + item.Description); } return listOFEventsToReturn; }