public ActionResult Index(FormCollection form, ProjectSearchModel projectSearchModel) { var list = from project in _dbContext.Projects.ToList() where ( (!String.IsNullOrEmpty(projectSearchModel.ProjectName) ? project.ProjectName.Contains(projectSearchModel.ProjectName, StringComparison.OrdinalIgnoreCase) : true ) && ((projectSearchModel.Id != default(int)) ? projectSearchModel.Id == project.Id : true ) ) select project; projectSearchModel.Projects = list; projectSearchModel.Queryables = GetQueryables(); return View(projectSearchModel); }
// GET: Projects public ActionResult Index() { ProjectSearchModel projectSearchModel = new ProjectSearchModel(); var list = from project in _dbContext.Projects.ToList() select project; projectSearchModel.Projects = list; projectSearchModel.Queryables = GetQueryables(); projectSearchModel.Id = default(int); return View(projectSearchModel); }