public ActionResult ShowAdvanceFilter(Spartan_Format_ConfigurationAdvanceSearchModel model)
        {
            if (ModelState.IsValid)
            {
                Session["AdvanceSearch"] = model;
                return(RedirectToAction("Index"));
            }
            ViewBag.Filter = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = Resources.Resources.BeginWith, Value = "1"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.EndWith, Value = "2"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Contains, Value = "4"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Exact, Value = "3"
                },
            };
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            return(View(model));
        }
        public ActionResult ShowAdvanceFilter(string previousFilters = "")
        {
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            var previousFiltersObj = new Spartan_Format_ConfigurationAdvanceSearchModel();

            if (previousFilters != "")
            {
                previousFiltersObj = (Spartan_Format_ConfigurationAdvanceSearchModel)(Session["AdvanceSearch"] ?? new Spartan_Format_ConfigurationAdvanceSearchModel());
            }

            ViewBag.Filter = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = Resources.Resources.BeginWith, Value = "1"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.EndWith, Value = "2"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Contains, Value = "4"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Exact, Value = "3"
                },
            };

            return(View(previousFiltersObj));
        }
        public string GetAdvanceFilter(Spartan_Format_ConfigurationAdvanceSearchModel filter)
        {
            var where = "";
            if (!string.IsNullOrEmpty(filter.FromFormat) || !string.IsNullOrEmpty(filter.ToFormat))
            {
                if (!string.IsNullOrEmpty(filter.FromFormat))
                {
                    where += " AND Spartan_Format_Configuration.Format >= " + filter.FromFormat;
                }
                if (!string.IsNullOrEmpty(filter.ToFormat))
                {
                    where += " AND Spartan_Format_Configuration.Format <= " + filter.ToFormat;
                }
            }

            if (!string.IsNullOrEmpty(filter.Query_To_Fill_Fields))
            {
                switch (filter.Query_To_Fill_FieldsFilter)
                {
                case Models.Filters.BeginWith:
                    where += " AND Spartan_Format_Configuration.Query_To_Fill_Fields LIKE '" + filter.Query_To_Fill_Fields + "%'";
                    break;

                case Models.Filters.EndWith:
                    where += " AND Spartan_Format_Configuration.Query_To_Fill_Fields LIKE '%" + filter.Query_To_Fill_Fields + "'";
                    break;

                case Models.Filters.Exact:
                    where += " AND Spartan_Format_Configuration.Query_To_Fill_Fields = '" + filter.Query_To_Fill_Fields + "'";
                    break;

                case Models.Filters.Contains:
                    where += " AND Spartan_Format_Configuration.Query_To_Fill_Fields LIKE '%" + filter.Query_To_Fill_Fields + "%'";
                    break;
                }
            }

            if (!string.IsNullOrEmpty(filter.Filter_to_Show))
            {
                switch (filter.Filter_to_ShowFilter)
                {
                case Models.Filters.BeginWith:
                    where += " AND Spartan_Format_Configuration.Filter_to_Show LIKE '" + filter.Filter_to_Show + "%'";
                    break;

                case Models.Filters.EndWith:
                    where += " AND Spartan_Format_Configuration.Filter_to_Show LIKE '%" + filter.Filter_to_Show + "'";
                    break;

                case Models.Filters.Exact:
                    where += " AND Spartan_Format_Configuration.Filter_to_Show = '" + filter.Filter_to_Show + "'";
                    break;

                case Models.Filters.Contains:
                    where += " AND Spartan_Format_Configuration.Filter_to_Show LIKE '%" + filter.Filter_to_Show + "%'";
                    break;
                }
            }


            where = new Regex(Regex.Escape("AND ")).Replace(where, "", 1);
            return(where);
        }