public ActionResult ShowAdvanceFilter(Spartan_WorkFlow_OperatorAdvanceSearchModel 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 string GetAdvanceFilter(Spartan_WorkFlow_OperatorAdvanceSearchModel filter)
        {
            var where = "";
            if (!string.IsNullOrEmpty(filter.FromOperatorId) || !string.IsNullOrEmpty(filter.ToOperatorId))
            {
                if (!string.IsNullOrEmpty(filter.FromOperatorId))
                {
                    where += " AND Spartan_WorkFlow_Operator.OperatorId >= " + filter.FromOperatorId;
                }
                if (!string.IsNullOrEmpty(filter.ToOperatorId))
                {
                    where += " AND Spartan_WorkFlow_Operator.OperatorId <= " + filter.ToOperatorId;
                }
            }

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

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

                case Models.Filters.Exact:
                    where += " AND Spartan_WorkFlow_Operator.Description = '" + filter.Description + "'";
                    break;

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


            where = new Regex(Regex.Escape("AND ")).Replace(where, "", 1);
            return(where);
        }
        public ActionResult ShowAdvanceFilter(string previousFilters = "")
        {
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            var previousFiltersObj = new Spartan_WorkFlow_OperatorAdvanceSearchModel();

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

            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));
        }