public ActionResult WebGrid(int page = 1, int rowsPerPage = 10, string sort = "ProductId", string sortDir = "ASC") { JointProductModels(); this._rowsPerPage = Convert.ToInt32(rowsPerPage); @ViewBag.rowsPerPage = rowsPerPage; var currentPage = GetListPage(page, rowsPerPage, sort, sortDir); var data = new PagedJointProductModel() { TotalRows = _jointProductModelList.Count(), PageSize = rowsPerPage, PagedProductModel = (IEnumerable<JointProductModel>)currentPage }; return View(data); }
public ActionResult WebGrid(int page = 1, int rowsPerPage = 10, string sort = "ProductId", string sortDir = "ASC") { var Products = XElement.Load(Server.MapPath("~/App_Data/XProducts.xml")). Elements("Product"). Select(x => new ProductModel( (int)x.Element("ProductID"), (string)x.Element("ProductName"), (int)x.Element("CategoryID"), (int)x.Element("SupplierID") )); var Categories = XElement.Load(Server.MapPath("~/App_Data/XCategories.xml")). Elements("Category"). Select(x => new CategoryModel( (int)x.Element("CategoryID"), (string)x.Element("CategoryName") )); var Suppliers = XElement.Load(Server.MapPath("~/App_Data/XSuppliers.xml")). Elements("Supplier"). Select(x => new SupplierModel( (int)x.Element("SupplierID"), (string)x.Element("CompanyName"), (string)x.Element("Country") )); int n = Products.Count(); //n.Dump("n"); var r = from p in Products join c in Categories on p.CategoryID equals c.CategoryID join s in Suppliers on p.SupplierID equals s.SupplierID orderby c.CategoryName, p.ProductID select new JointProductModel { ProductID = p.ProductID, ProductName = p.ProductName, CategoryName = c.CategoryName, CompanyName = s.CompanyName, Country = s.Country }; JointProductModelList = r.ToList(); if (rowsPerPage != null) { this.rowsPerPage = Convert.ToInt32(rowsPerPage); @ViewBag.rowsPerPage = rowsPerPage; } var currentPage = GetListPage(page, rowsPerPage, sort, sortDir); var data = new PagedJointProductModel() { TotalRows = JointProductModelList.Count(), PageSize = rowsPerPage, PagedProductModel = currentPage }; return View(data); }