Ejemplo n.º 1
0
        public JsonResult FailReviewUpdate(int questionId, string questionName, int ChatIntentId)
        {
            bool changed = true;

            try
            {
                ChatFailureResponse fail = db.ChatFailureResponse.Where(x => x.DefectId == questionId).FirstOrDefault();
                fail.Reviewed    = true;
                fail.UpdatedDate = DateTime.Now;
                changed          = true;

                ChatIntentQuestion question = new ChatIntentQuestion();
                question.QuestionDesc = questionName;
                question.ChatIntentId = ChatIntentId;
                db.ChatIntentQuestion.Add(question);

                db.SaveChanges();
                return(Json(changed, JsonRequestBehavior.AllowGet));
            }

            catch (Exception e)

            {
                Console.WriteLine(e.Message);
                return(Json(changed, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        public JsonResult QuestionUpdate(AskOperation askOperation)
        {
            AskDto             ask       = askOperation.ask;
            string             operation = askOperation.Operation;
            ChatIntentQuestion question  = new ChatIntentQuestion();
            bool changed = false;

            ask.UpdatedDate = DateTime.UtcNow;
            try
            {
                if (operation == "a")
                {
                    question.QuestionDesc = ask.QuestionDesc;
                    question.ChatIntentId = ask.ChatIntentId;
                    question.UpdatedDate  = DateTime.Now;
                    db.ChatIntentQuestion.Add(question);
                }
                else if (operation == "u")
                {
                    question = db.ChatIntentQuestion.Where(x => x.QuestionId == ask.QuestionId).FirstOrDefault();
                    question.QuestionDesc = ask.QuestionDesc;
                    question.ChatIntentId = ask.ChatIntentId;
                    question.UpdatedDate  = DateTime.Now;
                }
                else
                {
                    question = db.ChatIntentQuestion.Where(x => x.QuestionId == ask.QuestionId).FirstOrDefault();
                    db.ChatIntentQuestion.Attach(question);
                    db.ChatIntentQuestion.Remove(question);
                }
                changed = true;
                db.SaveChanges();
                return(Json(changed, JsonRequestBehavior.AllowGet));
            }

            catch (Exception e)

            {
                Console.WriteLine(e.Message);
                return(Json(changed, JsonRequestBehavior.AllowGet));
            }
        }