예제 #1
0
        public async Task <List <InvestmentTargetSetting> > GetListInvestmentTargetSetting()
        {
            var allPortfolio = await _portfolioManager.GetAllPortfolio();

            var listInvestmentTargetSetting = new List <InvestmentTargetSetting>();

            foreach (var portfolio in allPortfolio)
            {
                foreach (Duration duration in Enum.GetValues(typeof(Duration)))
                {
                    var investmentTargetSetting = await _unitOfWork.InvestmentTargetCMSRepository.GetAsync(i => i.PortfolioId == portfolio.Id && i.Duration == duration, "Portfolio");

                    if (investmentTargetSetting != null)
                    {
                        listInvestmentTargetSetting.Add(investmentTargetSetting);
                    }
                    else
                    {
                        var newInvestmentTargetSetting = new InvestmentTargetSetting()
                        {
                            Duration    = duration,
                            PortfolioId = portfolio.Id,
                            Value       = 0
                        };
                        var investmentTargetSettingAdded = _unitOfWork.InvestmentTargetCMSRepository.Add(newInvestmentTargetSetting);
                        await _unitOfWork.SaveChangesAsync();

                        listInvestmentTargetSetting.Add(investmentTargetSettingAdded);
                    }
                }
            }
            return(listInvestmentTargetSetting);
        }
예제 #2
0
        public async Task <InvestmentTargetSetting> AddConfiguration(InvestmentTargetSetting model)
        {
            try
            {
                var savedModel = _unitOfWork.InvestmentTargetCMSRepository.Add(model);
                await _unitOfWork.SaveChangesAsync();

                return(savedModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public async Task <InvestmentTargetSettingModel> AddConfiguration(InvestmentTargetSettingModel item)
        {
            try
            {
                InvestmentTargetSetting model      = _mapper.Map <InvestmentTargetSetting>(item);
                InvestmentTargetSetting addedModel = await _investmentTargetCMSManager.AddConfiguration(model);

                InvestmentTargetSettingModel savedModel = _mapper.Map <InvestmentTargetSettingModel>(addedModel);
                return(savedModel);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }