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 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; }