Ejemplo n.º 1
0
 public SellViewModel(AssetStore assetStore, IStockPriceService stockPriceService, ISellStockService sellStockService, IAccountStore accountStore)
 {
     AssetListingViewModel  = new AssetListingViewModel(assetStore);
     SearchSymbolCommand    = new SearchSymbolCommand(this, stockPriceService);
     SellStockCommand       = new SellStockCommand(this, sellStockService, accountStore);
     ErrorMessageViewModel  = new MessageViewModel();
     StatusMessageViewModel = new MessageViewModel();
 }
        public CommandStatus Handle(SellStockCommand command)
        {
            var portfolio = _repo.Load();

            portfolio.Remove(command.StockSymbol);

            _repo.Store(portfolio);
            return(new Success());
        }
Ejemplo n.º 3
0
        public bool SelectStockToSell(PortfolioStockQueryResult candidates, out SellStockCommand command)
        {
            SellStockCommand sellCmd = null;

            DisplaySellCandidates(candidates.MatchingStocks);
            Let_user_select_by_index("Enter index of stock to sell: ", index => {
                var toSell = candidates.MatchingStocks[index];
                sellCmd    = new SellStockCommand {
                    StockSymbol = toSell.Symbol
                };
            });

            command = sellCmd;
            return(command != null);
        }
Ejemplo n.º 4
0
        public static void Execute()
        {
            ConsoleExtension.WriteSeparator("Stock example");

            var stock = new Stock("Tesla", 5);

            var buyStock  = new BuyStockCommand(stock);
            var sellStock = new SellStockCommand(stock);

            var broker = new Broker();

            broker.TakeOrder(buyStock);
            broker.TakeOrder(sellStock);

            broker.ProcessOrders();
        }
 public CommandStatus Handle(SellStockCommand command)
 => _client.Execute <HttpCommandStatus>("sellstockcommand", command).CommandStatus;
Ejemplo n.º 6
0
 public HttpCommandStatus Handle([Payload] SellStockCommand command)
 => new HttpCommandStatus(Handler.Handle(command));