public InvestimentList <Investments> Get() { // Intancia de uma nova lista de investimentos (InvestimentList) var investimentList = new InvestimentList <Investments>(); // Intanciando a classe Random para gerar valores de rentabilidade aleatorios e siglas aleatorias; Random random = new Random(); //Gerando nova lista de investimentos com 6 for (int i = 0; i < 6; i++) { //Intanciando classes de investimentos var directTreasure = new DirectTreasure(); var investmentFunds = new InvestmentFunds(); var stockExchangeShares = new StockExchangeShares(); //Adicionando suas caracteristicas var initialsStockEx = Enum.GetNames(typeof(InitialsStockExchangeShare)); stockExchangeShares.Name = $"Ação{i}"; stockExchangeShares.MonthlyProfitability = random.Next(10, 50); stockExchangeShares.Initials = initialsStockEx[random.Next(initialsStockEx.Length)]; stockExchangeShares.Description = "Ação teste"; investmentFunds.Name = $"Fundo de Investimento{i + 1}"; investmentFunds.MonthlyProfitability = 21; investmentFunds.Description = "Teste Descrição"; investmentFunds.Initials = "SLA"; var valuesinitials = Enum.GetNames(typeof(InitialsTypeDirectTreasure)); directTreasure.Name = $"Tesouro direto{i + 1}"; directTreasure.Description = $"Descrição teste{i + 1}"; directTreasure.MonthlyProfitability = random.Next(1, 45); directTreasure.Initials = valuesinitials[random.Next(valuesinitials.Length)]; investimentList.SetInvestment(stockExchangeShares); investimentList.SetInvestment(directTreasure); investimentList.SetInvestment(investmentFunds); } return(investimentList); }
//Get para pegar as propriedades e atribuir valores e exibilos public InvestimentList <InvestmentFunds> Get() { //Nova instancia Lista de fundo de investimentos var investmentFundsList = new InvestimentList <InvestmentFunds>(); // Classe radom para valores aleatorios Random random = new Random(); //Gerando 6 fundos de investimentos com suas propridades for (int i = 0; i < 6; i++) { InvestmentFunds investmentFunds = new InvestmentFunds(); investmentFunds.Name = $"Teste{i}"; investmentFunds.MonthlyProfitability = 21; investmentFunds.Manager = managers[random.Next(managers.Length)]; investmentFunds.Description = "Teste Descrição"; investmentFunds.QuotaPrice = random.NextDouble() * 200; investmentFunds.TypeInvestmentFund = typesfunds[random.Next(typesfunds.Length)]; investmentFunds.Initials = "SLA"; investmentFundsList.SetInvestment(investmentFunds); } // retornando a lista de fundo de investimento return(investmentFundsList); }