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 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 ActionResult Regist(int questionId) { QuestionServices questionServices = new QuestionServices(); questionServices.Id = questionId.ToString(); List<QuestionModels> lst = questionServices.select(-1, -1); if (lst != null && lst.Count > 0) { ViewData["questionInfo"] = lst.First(); } return View(); }
public ActionResult Edit(int id) { QuestionServices serives = new QuestionServices(); serives.Id = id.ToString(); List<QuestionModels> list = serives.select(-1, -1); if (list != null && list.Count > 0) { ViewData["question"] = list.First(); } return View(); }
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()); }
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(); }
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; }