Пример #1
0
        public async Task <InvestmentTarget> AddInvestmentTarget(InvestmentTarget investmentTarget)
        {
            if (investmentTarget == null)
            {
                throw new InvalidParameterException();
            }
            try
            {
                investmentTarget.User = null;
                var currentUser = await _userManager.GetCurrentUser();

                investmentTarget.UserId = currentUser.Id;
                var interestRate = await GetInterestRate(currentUser.KVRR.Id, investmentTarget.Duration);

                var rt = (double)(1 + interestRate / (int)investmentTarget.Duration);
                var d  = (double)((int)investmentTarget.Duration);

                investmentTarget.OneTimeAmount = ((interestRate / (int)investmentTarget.Duration) * (investmentTarget.ExpectedAmount / (decimal)(Math.Pow(rt, d)) - currentUser.CurrentAccountAmount) / (decimal)(1 - (Math.Pow(rt, -d)))) / (int)investmentTarget.Frequency;
                var newInvestmentTarget = _unitOfWork.InvestmentTargetRepository.Add(investmentTarget);
                await _unitOfWork.SaveChangesAsync();

                return(newInvestmentTarget);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public async Task <InvestmentTargetModel> AddInvestmentTarget(InvestmentTargetModel investmentTargetModel)
        {
            InvestmentTarget investmentTarget = _mapper.Map <InvestmentTarget>(investmentTargetModel);
            var addedInvestmentTarget         = await _investmentTargetManager.AddInvestmentTarget(investmentTarget);

            return(_mapper.Map <InvestmentTargetModel>(addedInvestmentTarget));
        }
Пример #3
0
 public async Task UpdateInvestmentTarget(InvestmentTarget investmentTarget)
 {
     if (investmentTarget == null)
     {
         throw new InvalidParameterException();
     }
     try
     {
         investmentTarget.User = null;
         _unitOfWork.InvestmentTargetRepository.Update(investmentTarget);
         await _unitOfWork.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #4
0
 public async Task DeleteInvestmentTarget(InvestmentTargetModel investmentTargetModel)
 {
     InvestmentTarget investmentTarget = _mapper.Map <InvestmentTarget>(investmentTargetModel);
     await _investmentTargetManager.DeleteInvestmentTarget(investmentTarget);
 }