Exemple #1
0
        public async Task <LoanApplicationResponseDTO> ApproveApplication(long loanApplicationId, string userId)
        {
            LoanApplication loanApplication = await repository.FindAsync(loanApplicationId);


            this.entity.Attach(loanApplication);

            loanApplication.Status = LoanApplicationStatus.Approved;

            var statusLog = new LoanApplicationStatusLog
            {
                CreatedBy = userId,
                Status    = loanApplication.Status
            };

            loanApplication.StatusLogs.Add(statusLog);

            await this.dbContext.SaveChangesAsync();


            return(mapper.Map <LoanApplicationResponseDTO>(loanApplication));
        }
Exemple #2
0
        public async Task <LoanApplicationResponseDTO> ActivateApplication(long loanApplicationId, string userId)
        {
            LoanApplication loanApplication = await repository.FindAsync(loanApplicationId);

            this.entity.Attach(loanApplication);


            var ireversableStatuses = new List <LoanApplicationStatus> {
                LoanApplicationStatus.Approved,
                LoanApplicationStatus.Deleted,
                LoanApplicationStatus.Active
            };


            if (ireversableStatuses.Contains(loanApplication.Status))
            {
                return(mapper.Map <LoanApplicationResponseDTO>(loanApplication));
            }

            loanApplication.Status = LoanApplicationStatus.Active;


            var statusLog = new LoanApplicationStatusLog
            {
                CreatedBy = userId,
                Status    = LoanApplicationStatus.Active
            };

            loanApplication.StatusLogs.Add(statusLog);



            await this.dbContext.SaveChangesAsync();


            return(mapper.Map <LoanApplicationResponseDTO>(loanApplication));
        }