public virtual ActionResult Search(SurveySearchFilter filter) { ViewBag.ShowSurveyLink = true; ViewBag.AutoSubmit = false; var result = _surveyBusiness.Get(filter); if (!Request.IsAjaxRequest()) { return(View(result)); } return(PartialView(MVC.Survey.Views.Partials._SearchList, result.Result)); }
public IActionResponse <List <Survey> > Get(SurveySearchFilter filterModel) { var response = new ActionResponse <List <Survey> >(); var q = _survey.AsNoTracking().AsQueryable(); if (!string.IsNullOrWhiteSpace(filterModel.Subject)) { q = q.Where(x => x.Subject.Contains(filterModel.Subject)); } response.Result = q.OrderByDescending(x => x.SurveyId) .Take(filterModel.ItemsCount) .ToList(); return(response); }
public IEnumerable <Survey> SearchSurveys(SurveySearchFilter searchModel, string userId) { return(null); }
public IEnumerable <Survey> SearchSurveys(SurveySearchFilter surveySearchModel, string userId) { ComparisonOperators sentOperator; var query = String.IsNullOrEmpty(userId) ? Context.Surveys.OrderByDescending(s => s.Id) : Context.Surveys.Where(s => s.Name.Contains(surveySearchModel.SearchString) && s.UserId == userId); if (!String.IsNullOrWhiteSpace(surveySearchModel.SearchString)) { query = query.Where(s => s.Name.Contains(surveySearchModel.SearchString)); } if (!string.IsNullOrWhiteSpace(surveySearchModel.CreatedDateOperator)) { Enum.TryParse(surveySearchModel.CreatedDateOperator, out sentOperator); var createdDate = ConvertDate(surveySearchModel.CreatedDate); var createdDateTo = ConvertDate(surveySearchModel.CreatedDateTo); switch (sentOperator) { case ComparisonOperators.EQUAL: query = query.Where(p => DbFunctions.TruncateTime(p.Created) == createdDate.Date); break; case ComparisonOperators.LESSTHAN: query = query.Where(p => DbFunctions.TruncateTime(p.Created) < createdDate.Date); break; case ComparisonOperators.GREATERTHAN: query = query.Where(p => DbFunctions.TruncateTime(p.Created) > createdDate.Date); break; case ComparisonOperators.BETWEEN: query = query.Where(p => DbFunctions.TruncateTime(p.Created) >= createdDate.Date && DbFunctions.TruncateTime(p.Created) <= createdDateTo.Date); break; } } if (!string.IsNullOrWhiteSpace(surveySearchModel.ModifiedDateOperator)) { Enum.TryParse(surveySearchModel.ModifiedDateOperator, out sentOperator); var modifiedDate = ConvertDate(surveySearchModel.ModifiedDate); var modifiedDateTo = ConvertDate(surveySearchModel.ModifiedDateTo); switch (sentOperator) { case ComparisonOperators.EQUAL: query = query.Where(p => DbFunctions.TruncateTime(p.Modified) == modifiedDate.Date); break; case ComparisonOperators.LESSTHAN: query = query.Where(p => DbFunctions.TruncateTime(p.Modified) < modifiedDate.Date); break; case ComparisonOperators.GREATERTHAN: query = query.Where(p => DbFunctions.TruncateTime(p.Modified) > modifiedDate.Date); break; case ComparisonOperators.BETWEEN: query = query.Where(p => DbFunctions.TruncateTime(p.Modified) >= modifiedDate.Date && DbFunctions.TruncateTime(p.Modified) <= modifiedDateTo.Date); break; } } var listOfStatus = new List <SurveyStatus>(); if (surveySearchModel.Status.New) { listOfStatus.Add(SurveyStatus.New); } if (surveySearchModel.Status.Open) { listOfStatus.Add(SurveyStatus.Open); } if (surveySearchModel.Status.Closed) { listOfStatus.Add(SurveyStatus.Closed); } if (surveySearchModel.Status.TemprorarilyClosed) { listOfStatus.Add(SurveyStatus.TemprorarilyClosed); } return(query); }