public async Task <IList <LoanApplicationInfoDto> > FindLoanApplication(LoanApplicationSearchCriteriaDto criteria)
        {
            var queryAll = loanApplicationRepository.Query();

            if (!string.IsNullOrWhiteSpace(criteria.ApplicationNumber))
            {
                queryAll = queryAll.Where(a => a.Number == criteria.ApplicationNumber);
            }

            if (!string.IsNullOrWhiteSpace(criteria.CustomerNationalIdentifier))
            {
                queryAll = queryAll.Where(a => a.Customer.NationalIdentifier == criteria.CustomerNationalIdentifier);
            }

            if (!string.IsNullOrWhiteSpace(criteria.DecisionBy))
            {
                queryAll = queryAll.Where(a => a.DecisionBy.Login == criteria.DecisionBy);
            }

            if (!string.IsNullOrWhiteSpace(criteria.RegisteredBy))
            {
                queryAll = queryAll.Where(a => a.RegisteredBy.Login == criteria.RegisteredBy);
            }

            return(await queryAll.Select(a => new LoanApplicationInfoDto
            {
                Number = a.Number,
                Status = a.Status.ToString(),
                CustomerName = $"{a.Customer.FirstName} {a.Customer.LastName}",
                LoanAmount = a.LoanAmount,
                DecisionBy = a.DecisionBy != null ? a.DecisionBy.Login : null,
                DecisionDate = a.DecisionDate
            })
                   .ToListAsync());
        }
            private string BuildSearchQuery(LoanApplicationSearchCriteriaDto criteria)
            {
                var query = new StringBuilder();

                query.AppendLine("SELECT ");
                query.AppendLine("number AS Number, ");
                query.AppendLine("status AS Status, ");
                query.AppendLine("CustomerFirstName || ' ' || CustomerLastName AS CustomerName, ");
                query.AppendLine("decisionDate AS DecisionDate, ");
                query.AppendLine("LoanAmount AS LoanAmount, ");
                query.AppendLine("DecisionBy AS DecisionBy");
                query.AppendLine("FROM ddd_loan.loan_details_view");
                query.AppendLine("WHERE 1=1 ");

                if (!string.IsNullOrWhiteSpace(criteria.ApplicationNumber))
                {
                    query.AppendLine(" AND number = :ApplicationNumber");
                }

                if (!string.IsNullOrWhiteSpace(criteria.CustomerNationalIdentifier))
                {
                    query.AppendLine(" AND customerNationalIdentifier = :CustomerNationalIdentifier");
                }

                if (!string.IsNullOrWhiteSpace(criteria.DecisionBy))
                {
                    query.AppendLine(" AND decisionBy = :DecisionBy");
                }

                if (!string.IsNullOrWhiteSpace(criteria.RegisteredBy))
                {
                    query.AppendLine(" AND registeredBy = :RegisteredBy");
                }

                return(query.ToString());
            }
예제 #3
0
 public async Task <IEnumerable <LoanApplicationInfoDto> > Find([FromBody] LoanApplicationSearchCriteriaDto criteria)
 {
     return(await bus.Send(new FindLoanApplications.Query {
         Criteria = criteria
     }));
 }
예제 #4
0
 public async Task <IList <LoanApplicationInfoDto> > Find([FromBody] LoanApplicationSearchCriteriaDto criteria)
 {
     return(await loanApplicationService.FindLoanApplication(criteria));
 }
예제 #5
0
 public IList <LoanApplicationInfoDto> FindLoadApplication(LoanApplicationSearchCriteriaDto criteria)
 {
     return(new List <LoanApplicationInfoDto>());
 }