public ActionResult ShowAdvanceFilter(string previousFilters = "") { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_Report_Presentation_TypeApiConsumer.SetAuthHeader(_tokenManager.Token); var Spartan_Report_Presentation_Types = _ISpartan_Report_Presentation_TypeApiConsumer.SelAll(true); if (Spartan_Report_Presentation_Types != null && Spartan_Report_Presentation_Types.Resource != null) { ViewBag.Spartan_Report_Presentation_Types = Spartan_Report_Presentation_Types.Resource.Select(m => new SelectListItem { Text = m.Description.ToString(), Value = Convert.ToString(m.PresentationTypeId) }).ToList(); } var previousFiltersObj = new Spartan_Report_Presentation_ViewAdvanceSearchModel(); if (previousFilters != "") { previousFiltersObj = (Spartan_Report_Presentation_ViewAdvanceSearchModel)(Session["AdvanceSearch"] ?? new Spartan_Report_Presentation_ViewAdvanceSearchModel()); } 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_Report_Presentation_ViewAdvanceSearchModel filter) { var where = ""; if (!string.IsNullOrEmpty(filter.FromPresentationViewId) || !string.IsNullOrEmpty(filter.ToPresentationViewId)) { if (!string.IsNullOrEmpty(filter.FromPresentationViewId)) { where += " AND Spartan_Report_Presentation_View.PresentationViewId >= " + filter.FromPresentationViewId; } if (!string.IsNullOrEmpty(filter.ToPresentationViewId)) { where += " AND Spartan_Report_Presentation_View.PresentationViewId <= " + filter.ToPresentationViewId; } } if (!string.IsNullOrEmpty(filter.Description)) { switch (filter.DescriptionFilter) { case Models.Filters.BeginWith: where += " AND Spartan_Report_Presentation_View.Description LIKE '" + filter.Description + "%'"; break; case Models.Filters.EndWith: where += " AND Spartan_Report_Presentation_View.Description LIKE '%" + filter.Description + "'"; break; case Models.Filters.Exact: where += " AND Spartan_Report_Presentation_View.Description = '" + filter.Description + "'"; break; case Models.Filters.Contains: where += " AND Spartan_Report_Presentation_View.Description LIKE '%" + filter.Description + "%'"; break; } } if (!string.IsNullOrEmpty(filter.AdvancePresentation_Type)) { switch (filter.Presentation_TypeFilter) { case Models.Filters.BeginWith: where += " AND Spartan_Report_Presentation_Type.Description LIKE '" + filter.AdvancePresentation_Type + "%'"; break; case Models.Filters.EndWith: where += " AND Spartan_Report_Presentation_Type.Description LIKE '%" + filter.AdvancePresentation_Type + "'"; break; case Models.Filters.Exact: where += " AND Spartan_Report_Presentation_Type.Description = '" + filter.AdvancePresentation_Type + "'"; break; case Models.Filters.Contains: where += " AND Spartan_Report_Presentation_Type.Description LIKE '%" + filter.AdvancePresentation_Type + "%'"; break; } } else if (filter.AdvancePresentation_TypeMultiple != null && filter.AdvancePresentation_TypeMultiple.Count() > 0) { var Presentation_TypeIds = string.Join(",", filter.AdvancePresentation_TypeMultiple); where += " AND Spartan_Report_Presentation_View.Presentation_Type In (" + Presentation_TypeIds + ")"; } where = new Regex(Regex.Escape("AND ")).Replace(where, "", 1); return(where); }