コード例 #1
0
        public void Sell(int amount, string code)
        {
            Wallet userWallet   = walletRepository.GetUserWallet(Context.User.Identity.Name);
            Wallet marketWallet = walletRepository.GetMarketWallet();

            TransactionErrorCode result = userWallet.Transfer(marketWallet, code, amount);

            walletRepository.Save();
            Clients.User(Context.User.Identity.Name).completeTransaction(result, (WalletViewModel)userWallet);
        }
コード例 #2
0
        public void Buy(int amount, string code)
        {
            var userWallet = new Wallet();
            TransactionErrorCode result = TransactionErrorCode.UnknownError;

            try
            {
                userWallet = walletRepository.GetUserWallet(Context.User.Identity.Name);
                Wallet marketWallet = walletRepository.GetMarketWallet();

                result = marketWallet.Transfer(userWallet, code, amount);

                walletRepository.Save();
            }
            catch { }

            Clients.User(Context.User.Identity.Name).completeTransaction(result, (WalletViewModel)userWallet);
        }