public static BOEventCollection GetEventsToProcess(int internalStatus, int numberOfEvents) { BOEventCollection a = new BOEventCollection(); SqlConnection con = new SqlConnection(BOBase.GetConnectionString()); con.Open(); try { SqlCommand cmd = new SqlCommand("P_Event_GetEventsToProcess", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@InternalStatus", SqlDbType.Int).Value = internalStatus; cmd.Parameters.Add("@Events", SqlDbType.Int).Value = numberOfEvents; SqlDataReader rdr = cmd.ExecuteReader(); try { while (rdr.Read()) { BOEvent businessObject = new BOEvent(rdr); a.Add(businessObject); } } finally { rdr.Close(); } } finally { con.Close(); } return a; }
public static BOEvent GetByLink(string url) { SqlConnection con = new SqlConnection(BOBase.GetConnectionString()); BOEvent ev = null; con.Open(); try { SqlCommand cmd = new SqlCommand("P_Event_GetByURL", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ExternalURL", SqlDbType.VarChar).Value = url; SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow); try { while (rdr.Read()) { ev = new BOEvent(rdr); } } finally { rdr.Close(); } } finally { con.Close(); } return ev; }
public ActionResult Create(EventViewModel model) { if (ModelState.IsValid) { var businessObject = new BOEvent(); Mapper.Map<EventViewModel, BOEvent>(model, businessObject); businessObject.Game = new BOGame(model.GameListID); _eventService.Save(businessObject); return RedirectToAction("Index"); } model.GameList = new SelectList (_gameService.GetAll(), SelectLists.DataValueField, SelectLists.DataTextField, SelectLists.UnitializedSelectValue); return View(model); }
public BOEventComparer(BOEvent.Columns column, BOEvent.SortDirections direction) { _column = column; _direction = direction; }
public BOEventCollection GetNewEvents() { BOEventCollection events = new BOEventCollection(); if (Name == "Dota 2") { // This code needs to be moved WebClient Client = new WebClient(); string HTML = Client.DownloadString(this.Link); HtmlDocument document = new HtmlDocument(); document.LoadHtml(HTML); List<HtmlNode> evs = document.DocumentNode.Descendants().Where(d => d.Name.Contains("tbody")).ToArray()[0].SelectNodes("tr").ToList(); evs.AddRange(document.DocumentNode.Descendants().Where(d => d.Name.Contains("tbody")).ToArray()[1].SelectNodes("tr").ToList()); evs.AddRange(document.DocumentNode.Descendants().Where(d => d.Name.Contains("tbody")).ToArray()[2].SelectNodes("tr").ToList()); foreach (HtmlNode row in evs) { bool onGoing = false; var columns = row.SelectNodes("td"); string name = Regex.Match(columns[0].FirstChild.Attributes["href"].Value, "(tournament= ?)([-\\w\\d: ]+)").Groups[2].Value; string link = "http://www.datdota.com/" + columns[0].FirstChild.Attributes["href"].Value.Replace(" ", "%20"); DateTime startDate; string strStartDate = columns[1].InnerText; DateTime.TryParse(strStartDate, out startDate); DateTime endDate = new DateTime(); string strEndDate = columns[2].InnerText; if (strEndDate == "TBD") onGoing = true; else DateTime.TryParse(strEndDate, out endDate); string location = columns[3].InnerText; long prizepool = long.Parse(columns[4].InnerText); BOEvent ev; if (BOEvent.CheckExistingWebsiteURL(link)) { ev = new BOEvent(); ev.InternalStatus = 0; } else { ev = BOEvent.GetByLink(link); } ev.URL = link; ev.StartDate = startDate; ev.EndDate = endDate; ev.Name = name; ev.Game = this; if (onGoing) ev.InternalStatus = 2; ev.Save(); Console.WriteLine("Updated Event " + ev.Name); } } return events; }
public void Save(BOEvent ev) { _eventRepository.Save(ev); }