public static void UpdateModuleAnswer(this MdAnswer mdAnsDb, ModuleQnAViewModel mdQnA) { mdAnsDb.ID = mdQnA.AnsID.GetValueOrDefault(); mdAnsDb.ContentHTML = HttpUtility.HtmlDecode(mdQnA.AnsContent); mdAnsDb.ContentText = Regex.Replace(HttpUtility.HtmlDecode(mdQnA.AnsContent), @"<(.|\n)*?>", ""); mdAnsDb.MQuestionID = mdQnA.QuesID; }
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; }
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; })); }