public void setSearchFilter(QuestionServices questionServices, QuestionViewhelper questionViewhelper)
 {
     if (!String.IsNullOrEmpty(questionViewhelper.KeySearch))
         questionServices.KeySearch = questionViewhelper.KeySearch;
     if (questionViewhelper.QuestionCategoryId != 0)
         questionServices.QuestionCategoryId = questionViewhelper.QuestionCategoryId.ToString();
 }
 public ActionResult ChangeState(QuestionViewhelper questionViewhelper)
 {
     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");
     }
     QuestionServices questionService;
     if (questionViewhelper.CheckID != null && questionViewhelper.CheckID.Length > 0)
     {
         foreach (var id in questionViewhelper.CheckID)
         {
             questionService = new QuestionServices();
             questionService.Id = id.ToString();
             List<QuestionModels> lstCmt = questionService.select(-1, -1);
             if (lstCmt != null && lstCmt.Count > 0)
             {
                 QuestionModels item = lstCmt.First();
                 item.HiddenFlg = questionViewhelper.ChangeState;
                 questionService.update(item);
             }
         }
     }
     saveData(questionViewhelper);
     return View("Index");
 }
        public QuestionViewhelper saveData(QuestionViewhelper questionViewhelper)
        {
            QuestionCategoryServices questionCategoryServices = new QuestionCategoryServices();
            questionCategoryServices.addOrderBy("order_number", Constant.ORDER_ASC);
            List<QuestionCategoryModels> lstQuestionCategory = questionCategoryServices.select(-1, -1);
            questionViewhelper.LstQuestionCategory = lstQuestionCategory;

            QuestionServices questionServices = new QuestionServices();
            questionServices.HiddenFlg = Boolean.FalseString;
            questionServices.QuestionInAnswer = "TRUE";
            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);
                questionViewhelper.LstQuestion = lstQuestion;
            }
            ViewData["questionViewhelper"] = questionViewhelper;
            return questionViewhelper;
        }
 public ActionResult Index(QuestionViewhelper questionViewhelper)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_HOIDAP, Session.getCurrentUser().username, TypeAudit.Delete)
         || !SercurityServices.HasPermission((int)TypeModule.MODULE_HOIDAP, Session.getCurrentUser().username, TypeAudit.AnswerQuestion))
     {
         return Redirect("/admin/error/error403");
     }
     saveData(questionViewhelper);
     return View();
 }
 public ActionResult Index(QuestionViewhelper questionViewhelper)
 {
     saveData(questionViewhelper);
     return View();
 }
 //
 // GET: /Answer/
 public ActionResult Index()
 {
     QuestionViewhelper questionViewhelper = new QuestionViewhelper();
     saveData(questionViewhelper);
     return View();
 }
 public void setSearchFilter(QuestionServices questionServices, QuestionViewhelper questionViewhelper)
 {
     if (!String.IsNullOrWhiteSpace(questionViewhelper.KeySearch))
         questionServices.KeySearch = questionViewhelper.KeySearch;
     if (!String.IsNullOrWhiteSpace(questionViewhelper.ChangeFilter))
         questionServices.QuestionCategoryId = questionViewhelper.ChangeFilter;
 }
        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;
        }