Exemplo n.º 1
0
        public ActionResult ShowAdvanceFilter(Spartan_ObjectAdvanceSearchModel 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));
        }
Exemplo n.º 2
0
        public string GetAdvanceFilter(Spartan_ObjectAdvanceSearchModel filter)
        {
            var where = "";
            if (!string.IsNullOrEmpty(filter.FromObject_Id) || !string.IsNullOrEmpty(filter.ToObject_Id))
            {
                if (!string.IsNullOrEmpty(filter.FromObject_Id))
                {
                    where += " AND Spartan_Object.Object_Id >= " + filter.FromObject_Id;
                }
                if (!string.IsNullOrEmpty(filter.ToObject_Id))
                {
                    where += " AND Spartan_Object.Object_Id <= " + filter.ToObject_Id;
                }
            }

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

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

                case Models.Filters.Exact:
                    where += " AND Spartan_Object.Name = '" + filter.Name + "'";
                    break;

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


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



            var previousFiltersObj = new Spartan_ObjectAdvanceSearchModel();

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

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