Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        public ActionResult Regist()
        {
            QuestionCategoryServices questionCategoryServices = new QuestionCategoryServices();
            questionCategoryServices.addOrderBy("order_number", Constant.ORDER_ASC);
            List<QuestionCategoryModels> lstQuestionCategory = questionCategoryServices.select(-1, -1);
            ViewData["lstQuestionCategory"] = lstQuestionCategory;

            ViewData["questionModel"] = new QuestionModels();
            return View();
        }
 public ActionResult Edit(int id)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_HOIDAP, Session.getCurrentUser().username, TypeAudit.QuestionCategory))
     {
         return Redirect("/admin/error/error403");
     }
     QuestionCategoryServices serives = new QuestionCategoryServices();
     serives.Id = id.ToString();
     List<QuestionCategoryModels> list = serives.select(-1, -1);
     if (list != null && list.Count > 0)
     {
         ViewData["questionCategory"] = list.First();
     }
     return View();
 }
Ejemplo n.º 4
0
        public ActionResult SaveRegist(QuestionModels item, String captcha) {
            ViewData["questionModel"] = item;
            if (captcha != null)
            {
                string getCaptcha = HttpContext.Session["captcha"].ToString();
                if (captcha == getCaptcha)
                    ViewData["captcha"] = "You're right";
                else {
                    QuestionCategoryServices questionCategoryServices = new QuestionCategoryServices();
                    questionCategoryServices.addOrderBy("order_number", Constant.ORDER_ASC);
                    List<QuestionCategoryModels> lstQuestionCategory = questionCategoryServices.select(-1, -1);
                    ViewData["lstQuestionCategory"] = lstQuestionCategory;
                    ViewData["questionModel"] = item;
                    return View("Regist");
                }
            }
            if (Request.Files.Count > 0)
            {
                var fileName = string.Empty;
                var file = Request.Files[0];
                var bytes = new byte[file.ContentLength];
                if (bytes.Length > 0)
                {
                    file.InputStream.Read(bytes, 0, file.ContentLength);
                    item.AttachFileName = fileName = (file.FileName.IndexOf('\\') != -1 ? file.FileName.Substring(file.FileName.LastIndexOf('\\') + 1) : file.FileName);

                    var fileFolder = fileSaveFolder;
                    var fileDir = Server.MapPath("/") + fileFolder;
                    if (!System.IO.Directory.Exists(fileDir)) System.IO.Directory.CreateDirectory(fileDir);
                    var filePath = fileDir + "\\" + fileName.Substring(0, fileName.LastIndexOf(".")) + "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + fileName.Substring(fileName.LastIndexOf("."));
                    System.IO.File.WriteAllBytes(filePath, bytes);
                    item.AttachFilePath = filePath.Replace("\\", "/");
                }
            }
            item.HiddenFlg = true;
            item.QuestionDatetime = DateTime.Now;

            QuestionServices questionServices = new QuestionServices();
            questionServices.insert(item);
            return Redirect("Index");
        }
Ejemplo n.º 5
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.º 6
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;
        }
        public QuestionCategoryViewhelper saveData(QuestionCategoryViewhelper questionCategoryViewhelper)
        {
            QuestionCategoryServices questionCategoryServices = new QuestionCategoryServices();
            setSearchFilter(questionCategoryServices, questionCategoryViewhelper);

            int totalCount = questionCategoryServices.totalCount();
            questionCategoryViewhelper.TotalCount = totalCount;

            if (questionCategoryViewhelper.TotalCount > 0)
            {
                int totalPage = pageCalculation(totalCount, Constant.limit);
                questionCategoryViewhelper.TotalPage = totalPage;
                questionCategoryViewhelper.Page = pageTransition(questionCategoryViewhelper.Direction, questionCategoryViewhelper.Page, totalPage);
                questionCategoryViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, questionCategoryViewhelper.Page);
                questionCategoryViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, questionCategoryViewhelper.Page, questionCategoryViewhelper.FirstPage);
                questionCategoryServices.addOrderBy("order_number", "ASC");
                List<QuestionCategoryModels> lstQuestionCategory = questionCategoryServices.select(questionCategoryViewhelper.Page, Constant.limit);
                questionCategoryViewhelper.LstQuestionCategory = lstQuestionCategory;
            }
            ViewData["questionCategoryViewhelper"] = questionCategoryViewhelper;
            return questionCategoryViewhelper;
        }