コード例 #1
0
 public static void UpdateModuleQuestion(this MdQuestion mdQuesDb, ModuleQnAViewModel mdQnA)
 {
     mdQuesDb.ID          = mdQnA.QuesID.GetValueOrDefault();
     mdQuesDb.ContentHTML = HttpUtility.HtmlDecode(mdQnA.QuesContent);
     mdQuesDb.ContentText = Regex.Replace(HttpUtility.HtmlDecode(mdQnA.QuesContent), @"<(.|\n)*?>", "");
     mdQuesDb.AreaID      = mdQnA.AreaID;
     mdQuesDb.CreatedDate = DateTime.Now;
     mdQuesDb.BotID       = mdQnA.BotID;
 }
コード例 #2
0
        public HttpResponseMessage CreateUpdateQnA(HttpRequestMessage request, ModuleQnAViewModel mdQnA)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                bool result = true;
                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadGateway, ModelState);
                    return response;
                }
                MdQuestion mdQuesDb = new MdQuestion();
                MdAnswer mdAnsDb = new MdAnswer();
                mdQuesDb.BotID = mdQnA.BotID;
                mdAnsDb.BotID = mdQnA.BotID;
                ApiQnaNLRService apiNLR = new ApiQnaNLRService();
                if (mdQnA.QuesID == null)
                {
                    // add Ques
                    mdQuesDb.UpdateModuleQuestion(mdQnA);
                    _moduleSearchEngineService.CreateQuestion(mdQuesDb);
                    _moduleSearchEngineService.Save();
                    // add Ans
                    mdAnsDb.UpdateModuleAnswer(mdQnA);
                    mdAnsDb.MQuestionID = mdQuesDb.ID;
                    _moduleSearchEngineService.CreateAnswer(mdAnsDb);
                }
                else
                {
                    // update Ques
                    mdQuesDb.UpdateModuleQuestion(mdQnA);
                    _moduleSearchEngineService.UpdateQuestion(mdQuesDb);
                    // update Ans
                    mdAnsDb.UpdateModuleAnswer(mdQnA);
                    _moduleSearchEngineService.UpdateAnswer(mdAnsDb);
                }
                _moduleSearchEngineService.Save();

                // api training
                string nlrQuesID = mdQuesDb.ID.ToString();
                string nlrQuesContentText = mdQuesDb.ContentText;
                string nlrAnsContentText = mdAnsDb.ContentText;
                string nlrAnsContentHTML = mdAnsDb.ContentHTML;
                string nlrAreaName = mdQnA.AreaName;
                string nlrAreaID = (String.IsNullOrEmpty(mdQnA.AreaID.ToString()) == true ? "" : mdQnA.AreaID.ToString());
                string nlrBotID = mdQnA.BotID.ToString();
                //apiNLR.AddQues(nlrQuesID, nlrQuesContentText, nlrAnsContentText, nlrAreaName, nlrAnsContentHTML);

                response = request.CreateResponse(HttpStatusCode.OK, result);
                return response;
            }));
        }
コード例 #3
0
 public void UpdateQuestion(MdQuestion ques)
 {
     _mdQuesRepository.Update(ques);
 }
コード例 #4
0
 public MdQuestion CreateQuestion(MdQuestion ques)
 {
     return(_mdQuesRepository.Add(ques));
 }