//-------------------------------------- Contollers for ByManufactuer----------------------------------------------------------- public ActionResult ByManufacturer(string id, string brand, string category, string device) { var productService = new ProductService(Session); var products = productService.GetProductsByManufacturerService(id); var facetViewModel = new FacetViewModel(); List<Product> filteredProducts = products; if (brand != null) filteredProducts = products.Where(x => x.BrandName.Name.Equals(brand)).ToList(); if (category != null) filteredProducts = products.Where(x => x.ProductSubCategory.Name.Equals(category)).ToList(); facetViewModel.AddProducts(filteredProducts); foreach (var product in products) { var tempProd = product; if (!facetViewModel.ProductCategories.Any(c => c == tempProd.ProductSubCategory)) { //if (!product.ProductSubCategory.Name.Equals(category)) facetViewModel.ProductCategories.Add(product.ProductSubCategory); } if (!facetViewModel.BrandNames.Any(c => c == tempProd.BrandName)) { //if (!product.BrandName.Name.Equals(brand)) facetViewModel.BrandNames.Add(product.BrandName); } var tempDevices = tempProd.PhoneDevices.ToList(); //PhoneDevice prod1 = prod; //if (!tempDevices.Any(x => x == prod1)) facetViewModel.AssociatedDevices = tempDevices.GroupBy(x => x.Name).Select(x => x.First()).ToList(); } var filters = new StringBuilder(); if (brand != null) filters.Append(" And Brand › " + brand); if (category != null) filters.Append(" And Category › " + category); facetViewModel.Name = id; facetViewModel.FilterName = filters.ToString(); facetViewModel.ByManufacturer = true; var result = new ViewResult { ViewData = { Model = facetViewModel } }; return result; }
public ActionResult ByPhoneDevice(string id, string deviceID, string brand, string category, string manufacturer) { var dataService = new ProductService(Session); var products = dataService.GetProductsByDeviceNameService(deviceID); var facetViewModel = new FacetViewModel() { Name = deviceID, CarrierName = id}; List<Product> filteredProducts = products; if (brand != null) filteredProducts = products.Where(x => x.BrandName.Name.Equals(brand)).ToList(); if (category != null) filteredProducts = products.Where(x => x.ProductSubCategory.Name.Equals(category)).ToList(); if (manufacturer != null) filteredProducts = products.Where(x => x.Manufacturer.Name.Equals(manufacturer)).ToList(); facetViewModel.AddProducts(filteredProducts); foreach (var product in products) { var tempProd = product; if (!facetViewModel.ProductCategories.Any(c => c == tempProd.ProductSubCategory)) { facetViewModel.ProductCategories.Add(product.ProductSubCategory); } if (!facetViewModel.BrandNames.Any(c => c == tempProd.BrandName)) { facetViewModel.BrandNames.Add(product.BrandName); } if (!facetViewModel.Manufacturers.Any(c => c == tempProd.Manufacturer)) { facetViewModel.Manufacturers.Add(product.Manufacturer); } } var filters = new StringBuilder(); if (brand != null) filters.Append(" And Brand › " + brand); if (category != null) filters.Append(" And Category › " + category); facetViewModel.Name = deviceID; facetViewModel.FilterName = filters.ToString(); var result = new ViewResult { ViewData = { Model = facetViewModel } }; return result; }