public async Task <ActionResult <LoanApplicationRespObj> > GetOfferletterDecisionStatus([FromQuery] LoanApplicationSearchObj model)
 {
     try
     {
         var isDone = _repo.GetOfferletterDecisionStatus(model.LoanApplicationId);
         //var resplist = new List<LoanApplicationObj> { response };
         return(new LoanApplicationRespObj
         {
             Status = new APIResponseStatus {
                 IsSuccessful = isDone ? true : false, Message = new APIResponseMessage {
                     FriendlyMessage = isDone ? "Accepted" : "Not Accepted"
                 }
             }
         });
     }
     catch (Exception ex)
     {
         var errorCode = ErrorID.Generate(5);
         _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
         return(new LoanApplicationRespObj
         {
             Status = new APIResponseStatus {
                 IsSuccessful = false, Message = new APIResponseMessage {
                     FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode
                 }
             }
         });
     }
 }
 public async Task <ActionResult <LoanApplicationRespObj> > GetLoanRecommendationLog([FromQuery] LoanApplicationSearchObj model)
 {
     try
     {
         var response = _repo.GetLoanRecommendationLog(model.LoanApplicationId);
         //var resplist = new List<LoanApplicationObj> { response };
         return(new LoanApplicationRespObj
         {
             LoanRecommendationLogs = response,
             Status = new APIResponseStatus {
                 IsSuccessful = true, Message = new APIResponseMessage {
                     FriendlyMessage = "successful"
                 }
             }
         });
     }
     catch (Exception ex)
     {
         var errorCode = ErrorID.Generate(5);
         _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
         return(new LoanApplicationRespObj
         {
             Status = new APIResponseStatus {
                 IsSuccessful = false, Message = new APIResponseMessage {
                     FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode
                 }
             }
         });
     }
 }
        public async Task <ActionResult <LoanApplicationRespObj> > SubmitLoanForCreditAppraisal([FromQuery] LoanApplicationSearchObj model)
        {
            try
            {
                var response = await _repo.SubmitLoanForCreditAppraisal(model.LoanApplicationId);

                if (response.Status.IsSuccessful)
                {
                    var companyList = await _serverRequest.GetAllCompanyAsync();

                    var loanObj     = _context.credit_loanapplication.Find(model.LoanApplicationId);
                    var customerObj = _context.credit_loancustomer.Find(loanObj.CustomerId);

                    var productFeeList = _context.credit_productfee.Where(x => x.ProductId == loanObj.ApprovedProductId && x.Deleted == false).ToList();
                    foreach (var item in productFeeList)
                    {
                        decimal productamount = 0;
                        var     fee           = _context.credit_fee.FirstOrDefault(x => x.FeeId == item.FeeId && x.IsIntegral == false && x.Deleted == false);
                        if (item.ProductFeeType == 2)//Percentage
                        {
                            productamount = (loanObj.ApprovedAmount * Convert.ToDecimal(item.ProductAmount)) / 100;
                        }
                        else///Fixed
                        {
                            productamount = Convert.ToDecimal(item.ProductAmount);
                        }
                        if (fee != null)
                        {
                            CustomerTransactionObj customerTrans = new CustomerTransactionObj
                            {
                                CasaAccountNumber = customerObj.CASAAccountNumber,
                                Description       = "Payment of Non Integral Fee",
                                TransactionDate   = DateTime.Now,
                                ValueDate         = DateTime.Now,
                                TransactionType   = "Debit",
                                CreditAmount      = 0,
                                DebitAmount       = productamount,
                                Beneficiary       = companyList.companyStructures.FirstOrDefault(x => x.companyStructureId == loanObj.CompanyId)?.name,
                                ReferenceNo       = loanObj.ApplicationRefNumber,
                            };
                            _customerTrans.CustomerTransaction(customerTrans);
                        }
                    }
                }
                return(new LoanApplicationRespObj
                {
                    ResponseId = response.ResponseId,
                    Status = response.Status
                });
            }
            catch (Exception ex)
            {
                var errorCode = ErrorID.Generate(5);
                _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new LoanApplicationRespObj
                {
                    Status = new APIResponseStatus {
                        IsSuccessful = false, Message = new APIResponseMessage {
                            FriendlyMessage = "Error Occurred", TechnicalMessage = ex?.Message, MessageId = errorCode
                        }
                    }
                });
            }
        }