Exemplo n.º 1
0
 private Error NewPortfolio(PortfolioEvent e)
 {
     try
     {
         _mainModel.Account.CreatePortfolio(e.PortfolioName, _mainModel.VerifyStock);
         _currentPortfolio = _mainModel.Account.GetPortfolioByName(e.PortfolioName);
         Broadcast(new PortfolioEvent("portfolio", _currentPortfolio.Name));
     }
     catch (ArgumentException err)
     {
         return(new Error(err.Message));
     }
     return(Error.None);
 }
Exemplo n.º 2
0
 private Error DeletePortfolio(PortfolioEvent e)
 {
     try
     {
         _mainModel.Account.DeletePortfolio(e.PortfolioName, _mainModel.Stocks);
     }
     catch (ArgumentException err)
     {
         return(new Error(err.Message));
     }
     _currentPortfolio = null;
     Broadcast(new PortfolioEvent("portfolio", ""));
     return(Error.None);
 }
Exemplo n.º 3
0
 private Error ViewPortfolio(PortfolioEvent e)
 {
     if (_mainModel.Account.Portfolios.Exists((p) => p.Name == e.PortfolioName))
     {
         _currentPortfolio = _mainModel.Account.GetPortfolioByName(e.PortfolioName);
     }
     else
     {
         return(new Error("No portfolio exists with that name."));
     }
     if (_currentPortfolio != null)
     {
         Broadcast(new PortfolioEvent("portfolio", _currentPortfolio.Name));
     }
     else
     {
         Broadcast(new PortfolioEvent("portfolio", ""));
     }
     return(Error.None);
 }