public ActionResult Index(int? page, string selectedUsers, string diselectedUsers) { int pageNumber = page.HasValue ? page.Value : 1; UnitOfWork uof = new UnitOfWork(provider); var users = provider.GetAllUsers(); if (users.Count() == 0) { return RedirectToAction("Step1"); } string url = "http://" + Request.Url.Authority + "/Home/Index"; Paging pagingModel = PagingHelper.GetPagingModel(pageNumber, users.Count(), this.usersPerPage, url); ValueListIterator iterator = new ValueListIterator(provider, usersPerPage); List<User> pagedUsers = iterator.GetCurrentElement(pageNumber); int[] selected = null; int[] diselected; diselected = ResolveSelections(selectedUsers, diselectedUsers, ref selected); UrlOptions options = new UrlOptions() { UpdateUrl = String.Format("http://{0}/Home/UpdateRecord", Request.Url.Authority) }; SetChecked(pagedUsers, (int[])Session["selectedUsers"]); XmlDocument xml = XMLUserWriter.WriteXML(pagedUsers, pagingModel, options); string html = XSLTConverter.TransformFromMemory(xml, Server.MapPath(Url.Content("~/Converters/paging.xsl"))); return Content(html); }
public static XmlDocument WriteXML(IEnumerable<User> users, Paging pagingModel, UrlOptions options) { // Create the xml document container XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null); doc.AppendChild(dec);// Create the root element XmlElement root = doc.CreateElement("page"); doc.AppendChild(root); XmlElement usersEl = CreateUsersListNode(users, doc); root.AppendChild(usersEl); XmlElement paging = CreatePagingNode(pagingModel, doc); root.AppendChild(paging); XmlElement updateUrl = doc.CreateElement("updateAction"); updateUrl.InnerText = options.UpdateUrl; root.AppendChild(updateUrl); return doc; }