Exemplo n.º 1
0
        private List <AnswerModel> GetAnswers(int questionId)
        {
            var answerList = new List <Answer>();
            //var questionToReturn = new Question();
            var answerModelList = new List <AnswerModel>();

            using (var db = new ChatdataEntities())
            {
                try
                {
                    answerList = (from Answer in db.Answers
                                  where Answer.QuestionId == questionId
                                  select Answer)
                                 .ToList();
                }

                catch (Exception ex)
                {
                    var foo = ex.Message;
                }

                if (answerList.Count > 0)
                {
                    var autoMapper = AutoMapperBootStrapper.GetMapper();

                    answerModelList = autoMapper.Map <List <Answer>, List <AnswerModel> >(answerList);
                }
            }

            return(answerModelList);
        }
Exemplo n.º 2
0
        private int LogUserActivity(UserLogModel userLogMOdel)
        {
            using (var db = new ChatdataEntities())
            {
                var autoMapper = AutoMapperBootStrapper.GetMapper();

                var newUserLog = autoMapper.Map <UserLogModel, UserLog>(userLogMOdel);


                // Add the UserLog object to UserLogs
                db.UserLogs.Add(newUserLog);

                // Save the changes to the database
                db.SaveChanges();

                return(newUserLog.Id);
            }
        }
Exemplo n.º 3
0
        private bool LogErrorInfo(ErrorModel errorModel)
        {
            var success = false;

            using (var db = new ChatdataEntities())
            {
                var autoMapper = AutoMapperBootStrapper.GetMapper();

                var error = autoMapper.Map <ErrorModel, Error>(errorModel);

                db.Errors.Add(error);
                db.SaveChanges();

                success = true;
            }

            return(success);
        }
Exemplo n.º 4
0
        private QuestionModel GetQuestionByIntent(string intentName)
        {
            var questionList     = new List <Question>();
            var questionToReturn = new Question();
            var questionModel    = new QuestionModel();

            using (var db = new ChatdataEntities())
            {
                questionList = (from Question in db.Questions
                                where Question.LuisIntent == intentName
                                select Question).ToList();

                if (questionList.Count > 0)
                {
                    var autoMapper = AutoMapperBootStrapper.GetMapper();

                    questionModel = autoMapper.Map <Question, QuestionModel>(questionList[0]);
                }
            }

            return(questionModel);
        }