Exemple #1
0
        public Conversation ConversationBuilder(Envelope e)
        {
            Conversation conv = null;

            switch (e.Contents)
            {
            case GetPortfolioRequest m:
                conv = new GetPortfoliolResponseConversation(m.ConversationID);

                mock = new Mock <GetPortfolioReceiveState>(e, conv)
                {
                    CallBase = true
                };
                conv.SetInitialState(mock.Object as GetPortfolioReceiveState);
                break;
            }

            return(conv);
        }
Exemple #2
0
        private static Conversation HandleGetPortfolio(Envelope e)
        {
            Conversation conv = null;

            GetPortfolioRequest m = e.Contents as GetPortfolioRequest;

            var user = m.Account.Username;
            var pass = m.Account.Password;

            if (PortfolioManager.TryToGet(user, pass, out Portfolio portfolio))
            {
                conv = new GetPortfoliolResponseConversation(m.ConversationID);
                conv.SetInitialState(new GetPortfolioReceiveState(e, conv));
            }
            else
            {
                conv = new SendErrorMessageConversation(m.ConversationID);
                conv.SetInitialState(new SendErrorMessageState("Invalid login credentials.", e, conv, null, Config.GetInt(Config.BROKER_PROCESS_NUM)));
            }

            return(conv);
        }