public JsonResult <List <Models.ViewProjectDetail> > GetViewProjectsFiltered([FromBody] SearchSortParameter request) { var result = ProjectEntities.GetViewProjectDetails(); List <DataAccessLayer.ViewProjectDetails> projectList; IEnumerable <DataAccessLayer.ViewProjectDetails> searchResult; if (!string.IsNullOrEmpty(request.Search)) { searchResult = result.Where(x => x.ProjectDesc.Contains(request.Search)); } else { searchResult = result; } projectList = searchResult.AsQueryable().OrderByPropertyName(request.SortBy, request.Ascending).ToList(); var projectObj = Mapper.Map <List <DataAccessLayer.ViewProjectDetails>, List <Models.ViewProjectDetail> >(projectList); return(Json(projectObj)); }
public JsonResult <List <Models.ViewProjectDetail> > GetViewProjectsDetails(string searchBy, string sortBy, bool ascending) { var result = ProjectEntities.GetViewProjectDetails(); List <DataAccessLayer.ViewProjectDetails> projectList; IEnumerable <DataAccessLayer.ViewProjectDetails> searchResult; if (!string.IsNullOrEmpty(searchBy)) { searchResult = result.Where(x => x.ProjectDesc.Contains(searchBy)); } else { searchResult = result; } projectList = searchResult.AsQueryable().OrderByPropertyName(sortBy, ascending).ToList(); var projectObj = Mapper.Map <List <DataAccessLayer.ViewProjectDetails>, List <Models.ViewProjectDetail> >(projectList); return(Json(projectObj)); }