public ActionResult Edit_Post(SuppliersSingle suppliers, string sortOrder, string currentFilter, string searchString, int?page, string PgeSize) { try // handle exogenous exceptions { try // log all exceptions { SuppliersBusinessModelLayers suppliersBusinessModelLayers = new SuppliersBusinessModelLayers(); if (ModelState.IsValid) { //mm suppliersBusinessModelLayers.UpdateSuppliers(suppliers); return(RedirectToAction("List")); } ViewBag.CurrentSort = sortOrder; ViewBag.SupplierID = suppliers.SupplierID; BusinessLayer.Validation pge = new BusinessLayer.Validation(); List <SelectListItem> PgeSizes = pge.PageSize(); //Assigning generic list to ViewBag ViewBag.PgeSizeList = PgeSizes; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; //SUPPLIERS TABLE MASTER BusinessModelLayer.Suppliers.SuppliersMasterDetailModel pageModel = new BusinessModelLayer.Suppliers.SuppliersMasterDetailModel { Suppliers = suppliersBusinessModelLayers.GetAllSupplierss().Single(x => x.SupplierID == suppliers.SupplierID) }; int pageSize = 10; if (PgeSize != null) { Int32.TryParse(PgeSize, out pageSize); } ViewBag.PgeSize = pageSize; int pageNumber = (page ?? 1); //PRODUCTS DETAIL BEGIN ViewBag.ProductNameSortParm = String.IsNullOrEmpty(sortOrder) ? "ProductName_desc" : ""; ProductsBusinessModelLayers productsBusinessModelLayers = new ProductsBusinessModelLayers(); pageModel.ProductsVwDetl = productsBusinessModelLayers.GetAllVwproductss().FindAll(x => x.SupplierID == suppliers.SupplierID).ToList().ToPagedList(pageNumber, pageSize); if (!String.IsNullOrEmpty(searchString)) { pageModel.ProductsVwDetl = pageModel.ProductsVwDetl.Where(s => s.ProductName.ToString().ToLower().Contains(searchString.ToLower())).ToList().ToPagedList(pageNumber, pageSize); } switch (sortOrder) { case "ProductName_desc": pageModel.ProductsVwDetl = pageModel.ProductsVwDetl.OrderByDescending(s => s.ProductName).ToList().ToPagedList(pageNumber, pageSize); break; default: // ProductName ascending pageModel.ProductsVwDetl = pageModel.ProductsVwDetl.OrderBy(s => s.ProductName).ToList().ToPagedList(pageNumber, pageSize); break; } //PRODUCTS DETAIL END return(View(pageModel)); } catch (Exception ex) { BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging(); exlog.SendExcepToDB(ex); throw; } } catch (Exception) { throw; } }
public ActionResult Edit(int CategoryID, string sortOrder, string currentFilter, string searchString, int?page, string PgeSize) { try // handle exogenous exceptions { try // log all exceptions { ViewBag.CurrentSort = sortOrder; ViewBag.CategoryID = CategoryID; BusinessLayer.Validation pge = new BusinessLayer.Validation(); List <SelectListItem> PgeSizes = pge.PageSize(); //Assigning generic list to ViewBag ViewBag.PgeSizeList = PgeSizes; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; //CATEGORIES TABLE MASTER BusinessModelLayer.Categories.CategoriesMasterDetailModel pageModel = new BusinessModelLayer.Categories.CategoriesMasterDetailModel(); CategoriesBusinessModelLayers categoriesBusinessModelLayers = new CategoriesBusinessModelLayers(); Categories.CategoriesMasterDetailModel categoriesMasterDetailModel = new Categories.CategoriesMasterDetailModel(); pageModel.Categories = categoriesBusinessModelLayers.GetAllCategoriess().FirstOrDefault(x => x.CategoryID == CategoryID); int pageSize = 10; if (PgeSize != null) { Int32.TryParse(PgeSize, out pageSize); } ViewBag.PgeSize = pageSize; int pageNumber = (page ?? 1); //PRODUCTS DETAIL BEGIN ViewBag.CategoryIDSortParm = String.IsNullOrEmpty(sortOrder) ? "CategoryID_desc" : ""; ProductsBusinessModelLayers productsBusinessModelLayers = new ProductsBusinessModelLayers(); List <BusinessModelLayer.Vwproducts> productss = productsBusinessModelLayers.GetAllVwproductss().FindAll(x => x.CategoryID == CategoryID).ToList(); if (!String.IsNullOrEmpty(searchString)) { productss = productss.Where(s => s.CategoryID == CategoryID && s.ProductName.ToString().ToLower().Contains(searchString.ToLower())).ToList(); } switch (sortOrder) { case "CategoryID_desc": productss = productss.OrderByDescending(s => s.CategoryID).ToList(); break; default: // CategoryID ascending productss = productss.OrderBy(s => s.CategoryID).ToList(); break; } pageModel.ProductsVwDetl = productss.ToPagedList(pageNumber, pageSize); //PRODUCTS DETAIL END return(View(pageModel)); } catch (Exception ex) { BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging(); exlog.SendExcepToDB(ex); throw; } } catch (Exception) { throw; } }
public ViewResult List(string sortOrder, string currentFilter, string searchString, int?page, string PgeSize) { try // handle exogenous exceptions { try // log all exceptions { ViewBag.CurrentSort = sortOrder; ViewBag.ProductNameSortParm = String.IsNullOrEmpty(sortOrder) ? "ProductName_desc" : ""; BusinessLayer.Validation pge = new BusinessLayer.Validation(); List <SelectListItem> PgeSizes = pge.PageSize(); //Assigning generic list to ViewBag ViewBag.PgeSizeList = PgeSizes; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; ProductsBusinessModelLayers productsBusinessModelLayers = new ProductsBusinessModelLayers(); List <BusinessModelLayer.Vwproducts> vwproductss = productsBusinessModelLayers.GetAllVwproductss(); if (!String.IsNullOrEmpty(searchString)) { vwproductss = vwproductss.Where(s => s.ProductName.ToString().ToLower().Contains(searchString.ToLower())).ToList(); } switch (sortOrder) { case "ProductName_desc": vwproductss = vwproductss.OrderByDescending(s => s.ProductName).ToList(); break; //case "!!!": // vwproductss = vwproductss.OrderBy(s => s.!!!).ToList(); // break; //case "!!!_desc": // vwproductss = vwproductss.OrderByDescending(s => s.!!!).ToList(); // break; default: // ProductName ascending vwproductss = vwproductss.OrderBy(s => s.ProductName).ToList(); break; } int pageSize = 10; if (PgeSize != null) { Int32.TryParse(PgeSize, out pageSize); } ViewBag.PgeSize = pageSize; int pageNumber = (page ?? 1); return(View(vwproductss.ToPagedList(pageNumber, pageSize))); } catch (Exception ex) { BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging(); exlog.SendExcepToDB(ex); throw; } } catch (Exception) { throw; } }