/// <summary> /// dont touch this /// </summary> /// <param name="searchString"></param> /// <param name="defLoc"></param> /// <returns></returns> public List <ProductViewModel> GetProducts(string searchString, int defLoc) { // gets a list of products filtered by search string var list = _repository.GetProductsBySearchString(searchString, defLoc); List <ProductViewModel> pvmList = new List <ProductViewModel>(); // convert List<Product> to List<ProductViewModel> foreach (var l in list) { pvmList.Add(_mapperClass.ConvertProductToProductViewModel(l, 0)); } // return List<ProductViewModel> return(pvmList); }
/// <summary> /// Gets the Product List from the repository layer, converts it to ProductViewModel List, and returns converted list /// </summary> /// <param name="storeViewModel"></param> /// <returns></returns> public List <ProductViewModel> ProductsList(StoreViewModel storeViewModel) { //call Repo method to get a List<Products> List <Product> productList = _repository.ProductList(); // query inventory list for product quantity List <Inventory> i = new List <Inventory>(); i = _repository.InventoryList(); List <Inventory> shortenedInventoryList = i.Where(x => x.StoreLocationId == storeViewModel.LocationId).ToList(); //convert that List<Player> to List<PlayerViewModel> List <ProductViewModel> productViewModelList = new List <ProductViewModel>(); for (int j = 0; j < productList.Count; j++) { List <Inventory> singleInventory = shortenedInventoryList.Where(x => x.ProductId == productList.ElementAt(j).ProductId).ToList(); productViewModelList.Add(_mapperClass.ConvertProductToProductViewModel(productList.ElementAt(j))); productViewModelList.ElementAt(j).ProductQuantity = singleInventory.ElementAt(0).ProductQuantity; } return(productViewModelList); }