internal static void ProcessProperQuestion(NewQuestionNonsenseCheck newQuestionNonsenseCheck)
 {
     try
     {
         var result = ProcessChatbotLogic.ProcessChatbotReceiveQuestion(new List <ChatbotNewQuestionModel>()
         {
             new ChatbotNewQuestionModel(newQuestionNonsenseCheck)
         });
         if (result != null)
         {
             NLPWebSocketController.SendQuestionMatchRequest(result);
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Trace.Write(e.Message);
     }
 }
        private void HandleResponse(KeyValuePair <WEBSOCKET_RESPONSE_TYPE, List <BaseModel> > model)
        {
            //TODO: what should the websocket do with bad responses?
            if (model.Key == WEBSOCKET_RESPONSE_TYPE.NONE)
            {
                return;
            }

            switch (model.Key)
            {
            case WEBSOCKET_RESPONSE_TYPE.MATCH_QUESTION:
                try
                {
                    {
                        MatchQuestionLogicResponse result = ProcessNLPResponse.ProcessNLPMatchQuestionsResponse(model.Value.Cast <MatchQuestionModelResponse>().ToList().First());

                        if (result != null)
                        {
                            if (ServerUtilities.msgIdToUserID[result.Msg_id] is NewQuestion)
                            {
                                if (result.Match)
                                {
                                    ChatbotWebSocketController.SendAnswerToQuestion(new ChatbotNewAnswerModel(result));
                                }
                                else
                                {
                                    var temp = ProcessChatbotLogic.GenerateModelCompareToOpenQuestions((NewQuestion)ServerUtilities.msgIdToUserID[result.Msg_id]);
                                    if (temp != null)
                                    {
                                        NLPWebSocketController.SendQuestionMatchRequest(temp);
                                    }
                                }
                            }
                            else if (ServerUtilities.msgIdToUserID[result.Msg_id] is NewOpenQuestion)
                            {
                                if (result.Match)
                                {
                                    ChatbotWebSocketController.SendAnswerToQuestion(new ChatbotNewAnswerModel(result));
                                }
                                else
                                {
                                    int    question_id = ProcessChatbotLogic.SaveQuestionToDatabase((NewOpenQuestion)ServerUtilities.msgIdToUserID[result.Msg_id]);
                                    String user_id     = ((NewOpenQuestion)ServerUtilities.msgIdToUserID[((MatchQuestionModelResponse)model.Value.First()).msg_id]).user_id;
                                    ChatbotWebSocketController.SendAnswerToQuestion(new ServerResponseNoAnswerToQuestion(result, (MatchQuestionModelResponse)model.Value.First(), question_id));
                                    ProcessChatbotLogic.AddNewOpenAnswer(user_id, question_id);
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    System.Diagnostics.Trace.Write(e.Message);
                }
                break;

            case WEBSOCKET_RESPONSE_TYPE.OFFENSIVENESS:
            {
                try
                {
                    var result = ProcessNLPResponse.ProcessNLPOffensivenessResponse(model.Value.Cast <OffensivenessModelResponse>().ToList().First());
                    if (result is OffensivenessLogicResponse)
                    {
                        ProcessOffenseResult(result);
                    }
                }
                catch (Exception e)
                {
                    System.Diagnostics.Trace.Write(e.Message);
                }
            }
            break;

            case WEBSOCKET_RESPONSE_TYPE.NONSENSE:
            {
                try
                {
                    NonsenseLogicResponse result = ProcessNLPResponse.ProcessNLPNonsenseResponse(model.Value.Cast <NonsenseModelResponse>().ToList().First());
                    if (result is NonsenseLogicResponse)
                    {
                        ProcessNonsenseResult(result);
                        //SendQuestionOffenseRequest((NonsenseLogicResponse)result);
                    }
                }
                catch (Exception e)
                {
                    System.Diagnostics.Trace.Write(e.Message);
                }
            }
            break;
            }
        }