public ActionResult SaveRegist(AnswerModels item) {
            item.HiddenFlg = false;
            item.AnswerUsername = "******";
            item.AnswerDatetime = DateTime.Now;
            item.UpdateDatetime = DateTime.Now;
            item.UpdateUsername = "******";

            AnswerServices answerServices = new AnswerServices();
            answerServices.insert(item);

            QuestionServices questionServices = new QuestionServices();
            questionServices.Id = item.QuestionId.ToString();
            List<QuestionModels> lst = questionServices.select(-1, -1);
            if(lst != null && lst.Count > 0){
                QuestionModels questionInfo = new QuestionModels();
                questionInfo =  lst.First();
                questionInfo.HiddenFlg = false;
                questionInfo.QuestionDatetime = DateTime.Now;
                questionServices = new QuestionServices();
                questionServices.update(questionInfo);
            }

            return Redirect("/admin/question/answer?questionid=" + item.QuestionId.ToString());
        }
Ejemplo n.º 2
0
        public ActionResult Detail(int id)
        {
            QuestionCategoryServices questionCategoryServices = new QuestionCategoryServices();
            questionCategoryServices.addOrderBy("order_number", Constant.ORDER_ASC);
            List<QuestionCategoryModels> lstQuestionCategory = questionCategoryServices.select(-1, -1);
            ViewData["lstQuestionCategory"] = lstQuestionCategory;

            QuestionServices questionServices;
            questionServices = new QuestionServices();

            questionServices.Id = id.ToString();
            questionServices.HiddenFlg = Boolean.FalseString;
            List<QuestionModels> lst = questionServices.select(-1, -1);
            if (lst != null && lst.Count > 0) {
                ViewData["questionInfo"] = lst.First();
                questionServices = new QuestionServices();
                questionServices.QuestionInAnswer = "TRUE";
                questionServices.QuestionCategoryId = lst.First().CategoryId.ToString();
                ViewData["lstQuestion"] = questionServices.select(-1, -1);

                AnswerServices answerServices = new AnswerServices();
                answerServices.QuestionId = lst.First().Id.ToString();
                List<AnswerModels> lstAnswer = answerServices.select(-1, -1);
                //if (lstAnswer != null && lstAnswer.Count > 0) {
                UserServices userServices;
                foreach (var item in lstAnswer)
                {
                    userServices = new UserServices();
                    userServices.Username = item.AnswerUsername;
                    item.UserInfo = userServices.select(-1, -1).FirstOrDefault();
                }
                ViewData["lstAnswer"] = lstAnswer;
            }
            else
            {
                return Redirect("/error/error404");
            }
            return View();
        }
Ejemplo n.º 3
0
 public ActionResult Answer(int questionId)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_HOIDAP, Session.getCurrentUser().username, TypeAudit.AnswerQuestion))
     {
         return Redirect("/admin/error/error403");
     }
     AnswerServices answerServices = new AnswerServices();
     answerServices.QuestionId = questionId.ToString();
     List<AnswerModels> lstAnswer = answerServices.select(-1, -1);
     ViewData["lstAnswer"] = lstAnswer;
     ViewData["questionId"] = questionId;
     return View();
 }
Ejemplo n.º 4
0
        public QuestionViewhelper saveData(QuestionViewhelper questionViewhelper)
        {
            QuestionServices questionServices = new QuestionServices();
            setSearchFilter(questionServices, questionViewhelper);

            int totalCount = questionServices.totalCount();
            questionViewhelper.TotalCount = totalCount;

            if (questionViewhelper.TotalCount > 0)
            {
                int totalPage = pageCalculation(totalCount, Constant.limit);
                questionViewhelper.TotalPage = totalPage;
                questionViewhelper.Page = pageTransition(questionViewhelper.Direction, questionViewhelper.Page, totalPage);
                questionViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, questionViewhelper.Page);
                questionViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, questionViewhelper.Page, questionViewhelper.FirstPage);
                questionServices.addOrderBy("question_datetime", "DESC");
                List<QuestionModels> lstQuestion = questionServices.select(questionViewhelper.Page, Constant.limit);
                foreach (var item in lstQuestion)
                {
                    QuestionCategoryServices questionCategoryServices = new QuestionCategoryServices();
                    questionCategoryServices.Id = item.CategoryId.ToString();
                    List<QuestionCategoryModels> lst = questionCategoryServices.select(-1, -1);
                    if (lst != null && lst.Count > 0)
                    {
                        item.CategoryName = lst.First().Name;
                    }

                    AnswerServices answerServices = new AnswerServices();
                    answerServices.QuestionId = item.Id.ToString();
                    item.CountAnswer = answerServices.totalCount();
                }
                questionViewhelper.LstQuestion = lstQuestion;
            }
            QuestionCategoryServices questionCategoryServices1 = new QuestionCategoryServices();
            questionViewhelper.LstQuestionCategory = questionCategoryServices1.select(-1, -1);
            ViewData["questionViewhelper"] = questionViewhelper;
            return questionViewhelper;
        }
Ejemplo n.º 5
0
 public ActionResult changeStateAnswer(int[] checkID, Boolean state, int questionId){
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_HOIDAP, Session.getCurrentUser().username, TypeAudit.Delete))
     {
         return Redirect("/admin/error/error403");
     }
     AnswerServices answerServices;
     if (checkID != null && checkID.Length > 0) {
         foreach (var id in checkID)
         {
             answerServices = new AnswerServices();
             answerServices.Id = id.ToString();
             List<AnswerModels> lst = answerServices.select(-1, -1);
             if(lst != null && lst.Count > 0){
                 AnswerModels answerModel = lst.First();
                 answerModel.HiddenFlg = state;
                 answerModel.UpdateUsername = "******";
                 answerModel.UpdateDatetime = DateTime.Now;
                 answerServices.update(answerModel);
             }
         }
     }
     return Redirect("answer?questionid=" + questionId.ToString());
 }