private GetCustomerCreditDto GetCustomerCredit(CustomerScore customerScore, decimal monthlyIncome) { var customerCredit = new GetCustomerCreditDto { CreditResult = CreditResultType.Reject, CreditLimit = 0, CreditResultReason = string.Empty }; if (customerScore.Score < 500) { customerCredit.CreditResultReason = "Credit score is less than 500 points"; } else if (customerScore.Score >= 500 && customerScore.Score < 1000 && monthlyIncome < 5000) { customerCredit.CreditResultReason = "Success"; customerCredit.CreditResult = CreditResultType.Accept; customerCredit.CreditLimit = 10000; } else { customerCredit.CreditResultReason = "Success"; customerCredit.CreditResult = CreditResultType.Accept; customerCredit.CreditLimit = monthlyIncome * creditLimitMultiplier; } return(customerCredit); }
public GetCustomerCreditDto CheckCreditAvailibility(CustomerCreditDto dto) { var customerCredit = new GetCustomerCreditDto { CreditResult = CreditResultType.Reject, CreditLimit = 0, CreditResultReason = string.Empty }; try { if (dto != null) { // Normalde Kredi skoru bilgisi servisten gelmelidir. var customerScore = _customerScore.Get(x => x.IdentityNumber == dto.IdentityNumber); if (customerScore == null) { logger.Info($"Identity number could not found!"); return(customerCredit); } customerCredit = GetCustomerCredit(customerScore, dto.MonthlyIncome); CreateCustomer(dto, customerCredit.CreditLimit); CreateCustomerHistory(dto.IdentityNumber, customerCredit.CreditResult, customerScore.Score); //Sms gönderme işlemi _smsSender.SendSms(new SendSmsDto()); } return(customerCredit); } catch (Exception ex) { logger.Error($"An error occurred : {ex.Message}"); throw new Exception(ex.Message); } }