public List <SearchBGsResponseModel> Search(BGsSearchModel searchData) { try { using (var dbContext = new PMSEntities()) { var query = dbContext.tblBGsDatas.ToList(); if (query != null && query.Count > 0) { if (!string.IsNullOrEmpty(searchData.ProjectCode)) { query = query.Where(i => i.ProjectCode == searchData.ProjectCode).ToList(); } if (!string.IsNullOrEmpty(searchData.ProjectName)) { query = query.Where(i => i.ProjectName == searchData.ProjectName).ToList(); } if (!string.IsNullOrEmpty(searchData.WONo)) { query = query.Where(i => i.WONo.Contains(searchData.WONo)).ToList(); } if (!string.IsNullOrEmpty(searchData.BGNo)) { query = query.Where(i => i.BGNo.Contains(searchData.BGNo)).ToList(); } if (query != null && query.Count > 0) { return(query.Select(i => new SearchBGsResponseModel { Id = i.Id, BGsId = i.BGsId, ProjectCode = i.ProjectCode, ProjectName = i.ProjectName, WONo = i.WONo, BGNo = i.BGNo, BGDate = i.BGDate, FilePath = i.FilePath }).ToList()); } } } } catch (Exception ex) { } return(null); }
public JsonResult SearchBGs(BGsSearchModel searchModel) { var result = _bgsService.Search(searchModel); return(Json(result, JsonRequestBehavior.AllowGet)); }
public List <SearchBGsResponseModel> Search(BGsSearchModel searchData) { return(_bgsRepository.Search(searchData)); }