Пример #1
0
        public ActionResult ByCategory(string name, int CategoryID)
        {
            #region Init

            BusinessLogicHandler myHandler = new BusinessLogicHandler();
            SearchViewModel model = new SearchViewModel();
            Technology helper = new Technology();
            #endregion

            #region Get Devices By Category

            if (name != null)
            {
                try
                {
                    model.GadgetResults = myHandler.CategoryDeviceSearch(name);
                    model.TCategory = new TechCategory();
                    helper = (Technology)model.GadgetResults.Take(1).FirstOrDefault();
                    model.TCategory = myHandler.GetTechnologyType(helper.TechCategoryID);
                }
                catch
                {
                    model.GadgetResults = myHandler.DevicesByCategory(CategoryID);//Replace
                    model.TCategory = new TechCategory();
                    model.TCategory = myHandler.GetTechnologyType(CategoryID);
                }

            }
            if (CategoryID != 0)
            {
                model.GadgetResults = myHandler.DevicesByCategory(CategoryID);//Replace
                model.TCategory = new TechCategory();
                model.TCategory = myHandler.GetTechnologyType(CategoryID);
            }

            #endregion

            return View(model);
        }
Пример #2
0
        public ActionResult DevicesAdvanced(Device_Advanced model)
        {
            #region init Search
            BusinessLogicHandler myHandler = new BusinessLogicHandler();
            SearchViewModel SModel = new SearchViewModel();
            #endregion

            #region Execute Device Search

            if(model.Category == true)
            {
                if (model.RangeFrom != null && model.RangeTo == null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.CategoryFromQueryDeviceSeach("", model.RangeFrom.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.CategoryFromQueryDeviceSeach(model.Query, model.RangeFrom.GetValueOrDefault());
                }
                if (model.RangeTo != null && model.RangeFrom == null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.CategoryToQueryDeviceSearch("", model.RangeTo.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.CategoryToQueryDeviceSearch(model.Query, model.RangeTo.GetValueOrDefault());
                }
                if (model.RangeFrom != null && model.RangeTo != null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.CategoryBETWEENQueryDeviceSearch("", model.RangeFrom.GetValueOrDefault(), model.RangeTo.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.CategoryBETWEENQueryDeviceSearch(model.Query, model.RangeFrom.GetValueOrDefault(), model.RangeTo.GetValueOrDefault());
                }
                else
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.CategoryDeviceSearch("");
                    else
                        SModel.GadgetResults = myHandler.CategoryDeviceSearch(model.Query);
                }
            }
            if (model.Manufacturer == true)
            {
                if (model.RangeFrom != null && model.RangeTo == null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ManufacturerFromQueryDeviceSearch("", model.RangeFrom.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.ManufacturerFromQueryDeviceSearch(model.Query, model.RangeFrom.GetValueOrDefault());
                }
                if (model.RangeTo != null && model.RangeFrom == null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ManufacturerToQueryDeviceSearch("", model.RangeTo.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.ManufacturerToQueryDeviceSearch(model.Query, model.RangeTo.GetValueOrDefault());
                }
                if (model.RangeFrom != null && model.RangeTo != null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ManufacturerBETWEENQueryDeviceSearch("", model.RangeFrom.GetValueOrDefault(), model.RangeTo.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.ManufacturerBETWEENQueryDeviceSearch(model.Query, model.RangeFrom.GetValueOrDefault(), model.RangeTo.GetValueOrDefault());
                }
                else
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ManufacturerDeviceSearch("");
                    else
                        SModel.GadgetResults = myHandler.ManufacturerDeviceSearch(model.Query);
                }

            }
            if(model.ModelName == true)
            {
                if (model.RangeFrom != null && model.RangeTo == null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ModelNameFromQueryDeviceSearch("", model.RangeFrom.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.ModelNameFromQueryDeviceSearch(model.Query, model.RangeFrom.GetValueOrDefault());
                }
                if (model.RangeTo != null && model.RangeFrom == null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ModelNameToQueryDeviceSearch("", model.RangeTo.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.ModelNameToQueryDeviceSearch(model.Query, model.RangeTo.GetValueOrDefault());
                }
                if (model.RangeFrom != null && model.RangeTo != null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ModelNameBETWEENQueryDeviceSearch("", model.RangeFrom.GetValueOrDefault(), model.RangeTo.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.ModelNameBETWEENQueryDeviceSearch(model.Query, model.RangeFrom.GetValueOrDefault(), model.RangeTo.GetValueOrDefault());
                }
                else
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ModelNameDeviceSearch("");
                    else
                        SModel.GadgetResults = myHandler.ModelNameDeviceSearch(model.Query);
                }

            }
            if(model.ModelNumber == true)
            {
                if (model.RangeFrom != null && model.RangeTo == null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ModelNumberFromQueryDeviceSearch("", model.RangeFrom.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.ModelNumberFromQueryDeviceSearch(model.Query, model.RangeFrom.GetValueOrDefault());
                }
                if (model.RangeTo != null && model.RangeFrom == null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ModelNumberToQueryDeviceSearch("", model.RangeTo.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.ModelNumberToQueryDeviceSearch(model.Query, model.RangeTo.GetValueOrDefault());
                }
                if (model.RangeFrom != null && model.RangeTo != null)
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ModelNumberBETWEENQueryDeviceSearch("", model.RangeFrom.GetValueOrDefault(), model.RangeTo.GetValueOrDefault());
                    else
                        SModel.GadgetResults = myHandler.ModelNumberBETWEENQueryDeviceSearch(model.Query, model.RangeFrom.GetValueOrDefault(), model.RangeTo.GetValueOrDefault());
                }
                else
                {
                    if (model.Query == null)
                        SModel.GadgetResults = myHandler.ModelNumberSearch("");
                    else
                        SModel.GadgetResults = myHandler.ModelNumberSearch(model.Query);
                }

            }
            if(model.RangeFrom != null && model.RangeTo == null && model.ModelNumber == false && model.Manufacturer == false && model.ModelName == false && model.Category == false && model.Query == null)
            {
                SModel.GadgetResults = myHandler.ModelNumberFromQueryDeviceSearch("", model.RangeFrom.GetValueOrDefault());
            }
            if (model.RangeTo != null && model.RangeFrom == null && model.ModelNumber == false && model.Manufacturer == false && model.ModelName == false && model.Category == false && model.Query == null)
            {
                SModel.GadgetResults = myHandler.ModelNumberToQueryDeviceSearch("", model.RangeTo.GetValueOrDefault());
            }
            if (model.RangeFrom != null && model.RangeTo != null && model.ModelNumber == false && model.Manufacturer == false && model.ModelName == false && model.Category == false && model.Query == null)
            {
                SModel.GadgetResults = myHandler.ModelNumberBETWEENQueryDeviceSearch("", model.RangeFrom.GetValueOrDefault(), model.RangeTo.GetValueOrDefault());
            }

            #endregion

            return View(SModel);
        }