Ejemplo n.º 1
0
 public CreditModel(Credit credit, bool takePayments = true)
 {
     Id = credit.Id;
     StartDate = credit.StartDate;
     EndDate = credit.EndDate;
     StartAmount = credit.StartAmount;
     MainDebt = credit.MainDebt;
     PercentageDebt = credit.PercentageDebt;
     CreditTypeId = credit.CreditTypeId;
     ClientId = credit.ClientId;
     if (credit.CreditType != null)
     {
         CreditType = new CreditTypeModel(credit.CreditType);
     }
     if (credit.UserProfile != null)
     {
         Client = new UserViewModel(credit.UserProfile);
     }
     if (takePayments && credit.CreditPayment != null)
     {
         PaymentModels =
             credit.CreditPayment.Select(item => new CreditPaymentModel(item))
                 .OrderByDescending(item => item.Date)
                 .ToList();
     }
 }
Ejemplo n.º 2
0
 public void OpenCredit(RequestModel request)
 {
     if (request.Type != RequestType.Credit)
     {
         return;
     }
     var creditType = creditTypeReporsitory.GetCreditTypeById(request.CreditTypeId.Value);
     var date = dateService.GetCurrentDate();
     var credit = new Credit
     {
         ClientId = request.ClientId,
         StartAmount =  request.Amount,
         MainDebt = request.Amount,
         StartDate = date,
         EndDate = date + TimeSpan.FromTicks(creditType.ReturnTerm) + TimeSpan.FromDays(1),
         CreditTypeId = creditType.Id,
         RequestId = request.Id,
         PercentageDebt = 0
     };
     creditRepository.CreateCredit(credit);
 }