Exemple #1
0
        // GET: Search
        public ActionResult Index()
        {
            if (Session["sessionUser"] == "")
            {
                return(RedirectToAction("LoginPage", "UserLogin"));
            }
            Service service = new Service();

            MarketplaceWebPortalApp.Models.FanFilter fanFilter = new Models.FanFilter();
            var initialFanFilter = service.InitializeFanFilter(2010, 2020);

            fanFilter.minHeight   = initialFanFilter.minHeight;
            fanFilter.maxHeight   = initialFanFilter.maxHeight;
            fanFilter.minVoltage  = initialFanFilter.minVoltage;
            fanFilter.maxVoltage  = initialFanFilter.maxVoltage;
            fanFilter.minPower    = initialFanFilter.minPower;
            fanFilter.maxPower    = initialFanFilter.maxPower;
            fanFilter.minSpeed    = initialFanFilter.maxSpeed;
            fanFilter.maxSpeed    = initialFanFilter.maxPower;
            ViewData["minHeight"] = "Minimum Height = " + fanFilter.minHeight;
            return(View());
        }
        public ActionResult Index(string id)
        {
            Service         service    = new Service();
            List <Category> categories = service.GetCategory();

            ViewBag.Categories = categories;

            if (Session["sessionUser"] == "")
            {
                return(RedirectToAction("LoginPage", "UserLogin"));
            }

            var param = id ?? "2";

            TempData["sub_id"] = id;
            int num;

            try
            {
                num = Int32.Parse(param);
            }
            catch (FormatException)
            {
                num = 2;
            }
            if (Request.IsAjaxRequest())
            {
                ProductsByCategory products_category = new ProductsByCategory(num);
                List <Product>     returning_List    = products_category.ByCategory();
                return(Json(returning_List, JsonRequestBehavior.AllowGet));
            }


            if (num == 2)
            {
                //FAN subCategory filtering values.
                MarketplaceWebPortalApp.Models.FanFilter fanFilter = new Models.FanFilter();
                var initialFanFilter = service.InitializeFanFilter(2010, 2020);
                fanFilter.minHeight  = initialFanFilter.minHeight;
                fanFilter.maxHeight  = initialFanFilter.maxHeight;
                fanFilter.minVoltage = initialFanFilter.minVoltage;
                fanFilter.maxVoltage = initialFanFilter.maxVoltage;
                fanFilter.minPower   = initialFanFilter.minPower;
                fanFilter.maxPower   = initialFanFilter.maxPower;
                fanFilter.minSpeed   = initialFanFilter.minSpeed;
                fanFilter.maxSpeed   = initialFanFilter.maxSpeed;
                string json = new JavaScriptSerializer().Serialize(fanFilter);
                ViewData["jsonStr"] = json;
                ViewData["Fields"]  = "['Operating Voltage (VAC)   (Min & Max)','Power(W)   (Min & Max)','Fan Speed(RPM)  (Min & Max)','Height(in)   (Min & Max)']";
            }

            else if (num == 4)
            {
                //TABLET subCategory filtering values.
                MarketplaceWebPortalApp.Models.TabletFilter tabletFilter = new Models.TabletFilter();
                var initialTabletFilter = service.InitializeTabletFilter(2010, 2020);
                tabletFilter.minRAM     = initialTabletFilter.minRAM;
                tabletFilter.maxRAM     = initialTabletFilter.maxRAM;
                tabletFilter.minScreen  = initialTabletFilter.minScreen;
                tabletFilter.maxScreen  = initialTabletFilter.maxScreen;
                tabletFilter.minStorage = initialTabletFilter.minStorage;
                tabletFilter.maxStorage = initialTabletFilter.maxStorage;
                string json = new JavaScriptSerializer().Serialize(tabletFilter);
                ViewData["jsonStr"] = json;
                ViewData["Fields"]  = "['Screen Size(in)','Storage(GB)','RAM(GB)']";
            }

            else if (num == 10)
            {
                //SOFA subCategory filtering values.
                MarketplaceWebPortalApp.Models.SofaFilter sofaFilter = new Models.SofaFilter();
                var initialSofaFilter = service.InitializeSofaFilter(2010, 2021);
                sofaFilter.minLength = initialSofaFilter.minLength;
                sofaFilter.maxLength = initialSofaFilter.maxLength;
                string json = new JavaScriptSerializer().Serialize(sofaFilter);
                ViewData["jsonStr"] = json;
                ViewData["Fields"]  = "['Length(in)']";
            }
            TempData["sub_id_from_search"] = id;
            return(View());
        }