private void initialize() { productVMRepo = new ProductVMRepo(); productRepo = new ProductRepo(); manufacturerVMRepo = new ManufacturerVMRepo(); manufacturerRepo = new ManufacturerRepo(); supplierRepo = new SupplierRepo(); //add database update listener delegate productRepo.DatabaseUpdated += ProductsUpdateListener; dataGridViewProducts.DataSource = bsProducts; comboBoxManufacturer.DataSource = bsManufacturers; comboBoxSupplier.DataSource = bsSuppliers; refreshProductsData(); loadManufacturers(); loadSuppliers(); }
// GET: Home public ActionResult Index(bool?cancelOrder, string sortOrder, string searchString, string currentFilter, int?page) { if (searchString != null) { page = 1; } else { searchString = currentFilter; } ProductVMRepo productRepo = new ProductVMRepo(); IEnumerable <ProductVM> products = productRepo.GetAll(sortOrder, searchString); // Store current sort filter parameter. ViewBag.CurrentSort = sortOrder; ViewBag.CurrentFilter = searchString; ViewBag.SearchResults = products.Count(); ViewBag.Product_ASC = ProductVMRepo.PRODUCT; ViewBag.Product_DESC = ProductVMRepo.PRODUCT_DESC; ViewBag.Price_ASC = ProductVMRepo.PRICE; ViewBag.Price_DESC = ProductVMRepo.PRICE_DESC; if (cancelOrder != null) { // clear cart and end session... string sessionID = System.Web.HttpContext.Current.Session.SessionID; SessionHelper.RemoveCurrentSessionData(sessionID); // start again so can keep shopping SessionHelper.StoreNewSessionData(); } const int PAGE_SIZE = 6; int pageNumber = (page ?? 1); products = products.ToPagedList(pageNumber, PAGE_SIZE); return(View(products)); }