コード例 #1
0
ファイル: Broker.cs プロジェクト: KrasimirEtov/NES
        public string Sell(string assetName, decimal amount)
        {
            decimal price = MarketProp.AssetPrice(assetName);

            IAsset asset = Factory.CreateAsset(assetName, price, amount);

            UserSession.User.Wallet.RemoveAsset(asset);
            UserSession.User.Wallet.Cash += price * amount;
            PrinterManager.PrintMarket(UserSession.User, MarketProp);
            return($"Succesfully selled {amount} {assetName} " + (amount > 1 ? "assets" : "asset"));
        }
コード例 #2
0
ファイル: Broker.cs プロジェクト: KrasimirEtov/NES
        public string Buy(string assetName, decimal amount)
        {
            decimal price = MarketProp.AssetPrice(assetName);

            if (UserSession.User.Wallet.Cash >= price * amount)
            {
                IAsset asset = Factory.CreateAsset(assetName, price, amount);
                UserSession.User.Wallet.AddAsset(asset);
                UserSession.User.Wallet.Cash -= price * amount;
            }
            else
            {
                throw new ArgumentException("You don't have enough funds for this purchase.");
            }
            PrinterManager.PrintMarket(UserSession.User, MarketProp);
            return($"Succesfully purchased {amount} {assetName} " + (amount > 1 ? "assets" : "asset"));
        }
コード例 #3
0
ファイル: Broker.cs プロジェクト: KrasimirEtov/NES
 public string EndDayTraiding()
 {
     MarketProp.UpdatePrices();
     PrinterManager.PrintMarket(UserSession.User, MarketProp);
     return("Trading day has ended!");
 }
コード例 #4
0
ファイル: BrokerMock.cs プロジェクト: KrasimirEtov/NES
        public string EndDayTraiding()
        {
            MarketProp.UpdatePrices();

            return("Trading day has ended!");
        }