Ejemplo n.º 1
0
        public List <DepartmentDocumentSearchResponse> AdvancedSearch(DepartmentDocumentSearchRequest searchRequest)
        {
            var result = _dbContext.Transmittals
                         .AsNoTracking()
                         .Join(_dbContext.DepartmentDocuments, t => t.Id, d => d.TransmittalNumber,
                               (t, d) => new { t, d })
                         .Select(td => new DepartmentDocumentSearchResponse
            {
                TransmittalNumber        = td.t.Id,
                TransmittalStatus        = td.t.TransmittalStatus,
                DepartmentDocumentNumber = td.d.Id,
                FirstName   = td.d.FirstName,
                LastName    = td.d.LastName,
                CompanyName = td.d.CompanyName,
                CheckNumber = td.d.CheckNumber,
                CheckAmount = td.d.CheckAmount,
                CashListing = td.d.CashListing,
            });


            if (searchRequest.TransmittalNumber.HasValue)
            {
                result = result.Where(td => td.TransmittalNumber == searchRequest.TransmittalNumber);
            }

            if (searchRequest.DepartmentDocumentNumber.HasValue)
            {
                result = result.Where(td => td.DepartmentDocumentNumber == searchRequest.DepartmentDocumentNumber);
            }

            if (searchRequest.CheckNumber.HasValue)
            {
                result = result.Where(td => td.CheckNumber == searchRequest.CheckNumber);
            }

            if (!String.IsNullOrEmpty(searchRequest.TransmittalStatus))
            {
                result = result.Where(td => td.TransmittalStatus == searchRequest.TransmittalStatus);
            }

            if (!String.IsNullOrEmpty(searchRequest.FirstName))
            {
                result = result.Where(td => EF.Functions.Like(td.FirstName, searchRequest.FirstName + "%"));
            }

            if (!String.IsNullOrEmpty(searchRequest.LastName))
            {
                result = result.Where(td => EF.Functions.Like(td.LastName, searchRequest.LastName + "%"));
            }

            if (!String.IsNullOrEmpty(searchRequest.CompanyName))
            {
                result = result.Where(td => EF.Functions.Like(td.CompanyName, searchRequest.CompanyName + "%"));
            }

            return(result.ToList());
        }
Ejemplo n.º 2
0
 public virtual IActionResult SearchDepartmentDocuments([FromBody] DepartmentDocumentSearchRequest body)
 {
     try
     {
         return(new ObjectResult(_departmentDocumentSearchService.AdvancedSearch(body)));
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }
 public List <DepartmentDocumentSearchResponse> AdvancedSearch(DepartmentDocumentSearchRequest searchRequest)
 {
     return(_searchRepository.AdvancedSearch(searchRequest));
 }