Пример #1
0
        //---------------------------------Controllers for ByCarrier------------------------------------------
        public ActionResult ByCarrier(string id)
        {
            var dataService = new CarrierService(Session);
            var devices = dataService.GetPhoneDevicesByCarrierNameService(id);
            var facetViewModel = new FacetViewModel() {Name = id, AssociatedDevices = devices, Carriers = dataService.GetCarriers()};

            var result = new ViewResult
            {
                ViewData = { Model = facetViewModel }
            };
            return result;
        }
Пример #2
0
        //-------------------------------------- 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 &rsaquo; " + brand);
            if (category != null)
                filters.Append(" And Category &rsaquo; " + category);
            facetViewModel.Name = id;
            facetViewModel.FilterName = filters.ToString();
            facetViewModel.ByManufacturer = true;

            var result = new ViewResult
            {
                ViewData = { Model = facetViewModel }
            };
            return result;
        }
Пример #3
0
        public ActionResult ByProductCategory(string id)
        {
            var dataService = new ProductCategoryService(Session);
            var subCategories = dataService.GetSubCategoriesByCategoryService(id);
            var facetViewModel = new FacetViewModel()
                                     {
                                         SubCategoryViewModel = new SubCategoryViewModel {Name = id, ProductSubCategories = subCategories, ProductCategories = dataService.GetProductCategories() },

                                     };
            var result = new ViewResult
            {
                ViewData = { Model = facetViewModel }
            };
            return result;
        }
Пример #4
0
        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 &rsaquo; " + brand);
            if (category != null)
                filters.Append(" And Category &rsaquo; " + category);
            facetViewModel.Name = deviceID;
            facetViewModel.FilterName = filters.ToString();

            var result = new ViewResult
            {
                ViewData = { Model = facetViewModel }
            };
            return result;
        }