Ejemplo n.º 1
0
 public async Task<ActionResult> Details(int? id)
 {
     PortfolioViewModel portfolioViewModel = HttpContext.Session.GetObjectFromJson<PortfolioViewModel>("selected_port_viewmodel");
     if (id == null)
     {
         return HttpNotFound();
     }
     if ((portfolioViewModel == null) || (portfolioViewModel.ID != id))
     {
         Portfolio portfolio = await _context.Portfolio.Include(p => p.PortfolioAssets).SingleAsync(m => m.ID == id);
         if (portfolio == null)
         {
             return HttpNotFound();
         }
         Builder builder = new Builder(_context);
         PortfolioDomainModel portfolioDomainModel = builder.GetPortfolioDomainModel(portfolio);
         portfolioViewModel = builder.GetPortfolioViewModel(portfolioDomainModel);
         HttpContext.Session.SetObjectAsJson("selected_port_viewmodel", portfolioViewModel);
     }
     if (portfolioViewModel.Stocks.Count() < 1)
     {
         return RedirectToAction("AddStock", new { id = id });
     }
     return View(portfolioViewModel);
 }
Ejemplo n.º 2
0
        public IActionResult Index(int? id)
        {
            if (id == null)
            {
                return HttpNotFound();
            }

            PortfolioViewModel portfolioViewModel = HttpContext.Session.GetObjectFromJson<PortfolioViewModel>("selected_port_viewmodel");
            if (portfolioViewModel == null)
            {
                Portfolio portfolio = _context.Portfolio.Include(p => p.PortfolioAssets).Single(m => m.ID == id);
                if ((portfolio == null) || (portfolioViewModel.ID != id))
                {
                    return HttpNotFound();
                }
                Builder builder = new Builder(_context);
                PortfolioDomainModel portfolioDomainModel = builder.GetPortfolioDomainModel(portfolio);
                portfolioViewModel = builder.GetPortfolioViewModel(portfolioDomainModel);
                HttpContext.Session.SetObjectAsJson("selected_port_viewmodel", portfolioViewModel);
            }
            MonteCarloViewModel blankMonte = new MonteCarloViewModel();
           // blankMonte.PortfolioViewModel = portfolioViewModel;
            return View(blankMonte);
        }