示例#1
0
        private bool CheckOrderTerms()
        {
            //Check ticker, share, and secType to see if they are valid
            var tickerNotEmpty     = !string.IsNullOrEmpty(_orderTickerText);
            var shareQuantityValid = (_orderShareQuantity > 0);
            var securityTypeValid  = (_selectedSecurityType is Stock || _selectedSecurityType is MutualFund);

            //Check to see that selected security type matches the ticker
            bool secTypeMatch;
            var  tickerSecType = _portfolioManagementService.GetSecurityType(_orderTickerText, _selectedTradeType);

            if (tickerSecType == null)
            {
                var errorMessage = @"Your selected security type does not match the ticker's security type.";
                Messenger.Default.Send(new TradeMessage(_orderTickerText, _orderShareQuantity, errorMessage));
                return(false);
            }


            if (_selectedSecurityType is Stock && tickerSecType is Stock)
            {
                secTypeMatch = true;
            }
            else if (_selectedSecurityType is MutualFund && tickerSecType is MutualFund)
            {
                secTypeMatch = true;
            }
            else
            {
                secTypeMatch = false;
            }

            if (tickerNotEmpty && shareQuantityValid && securityTypeValid && secTypeMatch)
            {
                OrderTermsOK      = true;
                PreviewButtonText = "Order Terms OK";
                return(true);
            }

            else
            {
                OrderTermsOK      = false;
                PreviewButtonText = "Preview Order";
                return(false);
            }
        }