// GET: Events public ActionResult EventsView() { EventsGrid events = new EventsGrid(); if (SessionBag.Current.EventsXml != null && SessionBag.Current.EventsXml is XmlDocument && SessionBag.Current.EventsXmlReference != null && SessionBag.Current.EventsXmlReference is XmlDocument) { XmlDocument doc = SessionBag.Current.EventsXml as XmlDocument; XmlDocument docref = SessionBag.Current.EventsXmlReference as XmlDocument; XmlNodeList nodes = doc.SelectNodes("/Root/Data"); foreach (XmlNode node in nodes) { events.events.Add(new MVCEvents(node)); } nodes = docref.SelectNodes("/Root/Data"); foreach (XmlNode node in nodes) { events.eventsref.Add(new MVCEvents(node)); } events.events.Sort(); events.events.Reverse(); events.Bind(); ViewData.Model = events; } return(View()); }
public ActionResult PageSetEvent(MVCEvents model) { string venuekey = Request.Form["VenueList"]; if (venuekey == null || venuekey.Trim().Length == 0) { venuekey = Request.Form["VenueKey"]; } string eventkey = Request.Form["EventKey"]; string eventname = Request.Form["EventName"]; string eventdate = Request.Form["EventDate"]; string eventaddress = Request.Form["EventAddress"]; string eventemail = Request.Form["EventEmail"]; string command = Request.Form["command"]; if (command == null) { command = ""; } else { command = command.Trim().ToLower(); } if (command == "remove" && venuekey != null && venuekey.Trim().Length > 0 && eventkey != null && eventkey.Trim().Length > 0) { MVCEvents theevent = new MVCEvents(); theevent.VenueKey = venuekey; theevent.EventKey = eventkey; SingingClubClient client = new SingingClubClient(); client.Open(); string result = client.GeneralStore("TSCEvents", "DELETE", theevent.GetDataXml()); if (result != null && Utility.IsNumber(result) && int.Parse(result) > 0) { string _EventsXml = client.GeneralStore("TSCEvents", "GET", (new MVCEvents()).GetDataXml()); client.Close(); XmlDocument EventsXml = new XmlDocument(); XmlDocument EventsXmlReference = new XmlDocument(); EventsXml.LoadXml(_EventsXml); EventsXmlReference.LoadXml(_EventsXml); SessionBag.Current.EventsXml = EventsXml; SessionBag.Current.EventsXmlReference = EventsXmlReference; } } EventsGrid events = new EventsGrid(); if (SessionBag.Current.EventsXml != null && SessionBag.Current.EventsXml is XmlDocument && SessionBag.Current.EventsXmlReference != null && SessionBag.Current.EventsXmlReference is XmlDocument && venuekey != null && eventkey != null && venuekey.Trim().Length > 0 && eventkey.Trim().Length > 0) { XmlDocument doc = SessionBag.Current.EventsXml as XmlDocument; XmlDocument docref = SessionBag.Current.EventsXmlReference as XmlDocument; XmlNodeList nodes = doc.SelectNodes("/Root/Data"); bool found = false; foreach (XmlNode node in nodes) { MVCEvents add = new MVCEvents(node); if (add.VenueKey == venuekey && add.EventKey == eventkey) { SetText(node, "EventName", eventname); SetDate(node, "EventDate", eventdate); SetText(node, "EventAddress", eventaddress); SetText(node, "EventEmail", eventemail); add = new MVCEvents(node); found = true; } events.events.Add(add); } if (found == false && command != "remove") { XmlNode root = doc.SelectSingleNode("/Root"); if (root != null) { XmlNode data = doc.CreateNode(XmlNodeType.Element, "Data", null); if (data != null) { root.AppendChild(data); SetText(data, "VenueKey", venuekey); SetText(data, "EventKey", eventkey); SetText(data, "EventName", eventname); SetDate(data, "EventDate", eventdate); SetText(data, "EventAddress", eventaddress); SetText(data, "EventEmail", eventemail); MVCEvents add = new MVCEvents(data); events.events.Add(add); } } } nodes = docref.SelectNodes("/Root/Data"); foreach (XmlNode node in nodes) { events.eventsref.Add(new MVCEvents(node)); } events.events.Sort(); events.events.Reverse(); events.Bind(); ViewData.Model = events; } return(View()); }