Esempio n. 1
0
 public DepositModel(Deposit deposit, bool takePayments = true)
 {
     Id = deposit.Id;
     StartDate = deposit.StartDate;
     Balance = deposit.Balance;
     DepositTypeId = deposit.DepositTypeId;
     RequestId = deposit.RequestId;
     EndDate = deposit.EndDate;
     ClientId = deposit.ClientId;
     if (deposit.DepositType != null)
     {
         DepositType = new DepositTypeModel(deposit.DepositType);
     }
     if (deposit.UserProfile != null)
     {
         ClientModel = new UserViewModel(deposit.UserProfile);
     }
     if (takePayments && deposit.DepositPayment != null)
     {
         PaymentModels =
             deposit.DepositPayment.Select(item => new DepositPaymentModel(item))
                 .OrderByDescending(item => item.Date)
                 .ToList();
     }
 }
Esempio n. 2
0
 public void OpenDeposit(RequestModel request)
 {
     if (request.Type != RequestType.Deposit)
     {
         return;
     }
     var depositType = depositTypeRepository.GetDepositTypeById(request.DepositTypeId.Value);
     var date = dateService.GetCurrentDate();
     var deposit = new Deposit
     {
         Balance = request.Amount,
         DepositTypeId = depositType.Id,
         StartDate = date,
         EndDate = date + TimeSpan.FromTicks(depositType.ReturnTerm) + TimeSpan.FromDays(1),
         RequestId = request.Id,
         ClientId = request.ClientId
     };
     depositRepository.CreateDeposit(deposit);
 }