Пример #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);
        }
Пример #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);
            }
        }
Пример #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);
        }
Пример #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);
        }