public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Qtd,Preco")] Fundos fundos)
        {
            if (id != fundos.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fundos);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FundosExists(fundos.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fundos));
        }
Example #2
0
        /*public Fundos GetFundos(Guid id)
         * {
         *  Fundos empresa = repositorio.Get(id);
         *  if(empresa == null)
         *  {
         *      throw new HttpResponseException(HttpStatusCode.NotFound);
         *  }
         *  return empresa;
         * }*/

        public HttpResponseMessage PostEmpresa(Fundos empresa)
        {
            empresa = repositorio.Add(empresa);
            var    response = Request.CreateResponse <Fundos>(HttpStatusCode.Created, empresa);
            string uri      = Url.Link("DefaultApi", new { id = empresa.id });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
        /// <summary>Gera posição consolidada de todos os ativos</summary>
        public async Task <Consolidado> GerarPosicaoFundos()
        {
            Logger.LogInformation("Iniciando geração de posição em Tesouro Direto");

            Fundos fundos = null;

            await PositionService.ObterPosicaoFundos().ContinueWith(o => fundos = o.Result);

            return(fundos.MappingFundosToConsolidado());
        }
Example #4
0
        private void CalculationFundos(Responses.Investment investment, Fundos fundos)
        {
            const decimal discountPercentage = 0.15m;

            investment.Nome           = fundos.Nome;
            investment.ValorInvestido = fundos.CapitalInvestido;
            investment.ValorTotal     = fundos.ValorAtual;
            investment.Vencimento     = fundos.DataResgate;
            investment.Ir             = (fundos.ValorAtual - fundos.CapitalInvestido) * discountPercentage;
            investment.ValorResgate   = CalculationRescue(fundos.DataResgate, fundos.DataCompra, DateTime.Today, fundos.ValorAtual);
        }
        public async Task <IActionResult> Create([Bind("Id,Nome,Qtd,Preco")] Fundos fundos)
        {
            if (ModelState.IsValid)
            {
                _context.Add(fundos);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fundos));
        }
        /// <summary>Gera posição consolidada de todos os ativos</summary>
        public async Task <Consolidado> GerarPosicaoConsolidada()
        {
            Logger.LogInformation("Iniciando geração de posição consolidada");

            TesouroDireto tesouroDireto       = null;
            RendaFixa     rendaFixa           = null;
            Fundos        fundosInvestimentos = null;

            await Task.WhenAll(
                PositionService.ObterPosicaoTesouroDireto().ContinueWith(o => tesouroDireto = o.Result),
                PositionService.ObterPosicaoRendaFixa().ContinueWith(o => rendaFixa         = o.Result),
                PositionService.ObterPosicaoFundos().ContinueWith(o => fundosInvestimentos  = o.Result)
                );

            return(fundosInvestimentos.MappingPosicoesToConsolidado(tesouroDireto, rendaFixa));
        }