コード例 #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;
            }
        }