// GET: Products // GET: Movies public async Task <IActionResult> Index(string warehousew_location, string searchString) { IQueryable <string> w_locationQuery = from p in _context.Product orderby p.p_location select p.p_location; var products = from p in _context.Product select p; if (HttpContext.Session.GetInt32("USER_LOGIN_KEY") == null) { return(RedirectToAction("Login", "Account")); } if (!String.IsNullOrEmpty(searchString)) { products = products.Where(s => s.p_name.Contains(searchString)); } if (!string.IsNullOrEmpty(warehousew_location)) { products = products.Where(x => x.p_location == warehousew_location); } var warehousew_locationVM = new WarehouseLocationViewModel { p_locations = new SelectList(await w_locationQuery.Distinct().ToListAsync()), Products = await products.ToListAsync() }; return(View(warehousew_locationVM)); }
// GET: Warehouses public async Task <IActionResult> Index(string warehousew_location, string searchString) { // Use LINQ to get list of genres. IQueryable <string> w_locationQuery = from m in _context.Warehouse orderby m.w_location select m.w_location; var warehouses = from m in _context.Warehouse select m; if (!string.IsNullOrEmpty(searchString)) { warehouses = warehouses.Where(s => s.w_name.Contains(searchString)); } if (!string.IsNullOrEmpty(warehousew_location)) { warehouses = warehouses.Where(x => x.w_location == warehousew_location); } var warehousew_locationVM = new WarehouseLocationViewModel { w_locations = new SelectList(await w_locationQuery.Distinct().ToListAsync()), Warehouses = await warehouses.ToListAsync() }; return(View(warehousew_locationVM)); }