public void TestMethod3() { Tuple <int, int> result = PaginationUtils.GetPaginationBounds(9, 15); Assert.AreEqual(4, result.Item1); Assert.AreEqual(13, result.Item2); }
public void TestMethod4() { Tuple <int, int> result = PaginationUtils.GetPaginationBounds(1, 10); Assert.AreEqual(1, result.Item1); Assert.AreEqual(10, result.Item2); }
public MyExam() { InitializeComponent(); paginationUtils = new PaginationUtils(this.pnlPagination, this.customTipDialog1, hintFirst, hintLast, tipPageInput, pageSizeCollection, MultiPosibilityQuery); }
public IActionResult Index( int grammarPage = 1, string grammarSearchKey = "", string lookup = "") { #region For grammar int topicStart = (grammarPage - 1) * Math.Min(10, Config.PAGE_PAGINATION_LIMIT); var grammars = _TestCategoryManager.GetByPagination(TestCategory.READING, 1, topicStart, Math.Min(10, Config.PAGE_PAGINATION_LIMIT), grammarSearchKey); ViewBag.Grammars = grammars; ViewBag.GrammarSearchKey = grammarSearchKey; // Tạo đối tượng phân trang cho Grammars ViewBag.GrammarPagination = new Pagination(nameof(Index), NameUtils.ControllerName <DictionaryController>()) { PageKey = nameof(grammarPage), PageCurrent = grammarPage, NumberPage = PaginationUtils.TotalPageCount( _TestCategoryManager.CountFor(TestCategory.READING, 1, grammarSearchKey), Math.Min(10, Config.PAGE_PAGINATION_LIMIT)), Offset = Math.Min(10, Config.PAGE_PAGINATION_LIMIT) }; #endregion #region For search vocabulary ViewBag.Vocabularies = _VocabularyManager.LookUp(lookup ?? string.Empty); ViewBag.LookUp = lookup; #endregion return(View()); }
private IEnumerable <object> QuestionRender(string actionName, string typeCode, int partId, int questionPage = 1, int category = 0, string questionSearchKey = "") { int questionStart = (questionPage - 1) * Config.PAGE_PAGINATION_LIMIT; int total; if (partId == 1) { total = _ReadingPartOneManager.GetAll(category).Count(); } else { total = _ReadingPartTwoManager.GetAll(typeCode, partId, category).Count(); } // Tạo đối tượng phân trang cho Câu hỏi ViewBag.QuestionPagination = new Pagination(actionName, NameUtils.ControllerName <ReadingManagerController>()) { PageKey = nameof(questionPage), PageCurrent = questionPage, TypeKey = nameof(category), Type = "0", NumberPage = PaginationUtils.TotalPageCount(total, Config.PAGE_PAGINATION_LIMIT), Offset = Config.PAGE_PAGINATION_LIMIT }; if (category > 0) { var testCategory = _TestCategoryManager.Get(category); if (testCategory == null) { return(new List <object>()); } else { ViewBag.QuestionType = testCategory.Name ?? ""; if (partId == 1) { return(_ReadingPartOneManager.GetByPagination(category, questionStart, Config.PAGE_PAGINATION_LIMIT)); } else { return(_ReadingPartTwoManager.GetByPagination(category, typeCode, partId, questionStart, Config.PAGE_PAGINATION_LIMIT)); } } } else { ViewBag.QuestionType = "ALL"; if (partId == 1) { return(_ReadingPartOneManager.GetByPagination(questionStart, Config.PAGE_PAGINATION_LIMIT)); } else { return(_ReadingPartTwoManager.GetByPagination(typeCode, partId, questionStart, Config.PAGE_PAGINATION_LIMIT)); } } }
public IActionResult StudentTest(int studentId = -1, string type = "ALL", int page = 1, string searchKey = "", bool isUnRead = false) { // Truyền gửi tên bảng ViewBag.TableName = type.ToUpper(); ViewBag.SearchKey = searchKey; // Lấy các đếm chuẩn ViewBag.UserTestCountOfAll = _PieceOfTestManager.StudentTestCountOfType(User.Id(), "ALL", string.Empty, studentId, isUnRead); ViewBag.UserTestCountOfListening = _PieceOfTestManager.StudentTestCountOfType(User.Id(), TestCategory.LISTENING, string.Empty, studentId, isUnRead); ViewBag.UserTestCountOfReading = _PieceOfTestManager.StudentTestCountOfType(User.Id(), TestCategory.READING, string.Empty, studentId, isUnRead); ViewBag.UserTestCountOfSpeaking = _PieceOfTestManager.StudentTestCountOfType(User.Id(), TestCategory.SPEAKING, string.Empty, studentId, isUnRead); ViewBag.UserTestCountOfWriting = _PieceOfTestManager.StudentTestCountOfType(User.Id(), TestCategory.WRITING, string.Empty, studentId, isUnRead); ViewBag.UserTestCountOfCrash = _PieceOfTestManager.StudentTestCountOfType(User.Id(), "CRASH", string.Empty, studentId, isUnRead); // Tiến hành cấu hình phân trang int start = (page - 1) * Config.PAGE_PAGINATION_LIMIT; // Lấy danh sách List <PieceOfTest> PieceOfTests = _PieceOfTestManager.GetByPaginationSimpleForInstructor(User.Id(), type, start, Config.PAGE_PAGINATION_LIMIT, searchKey, studentId, isUnRead).ToList(); // Lấy một số thông tin cần thiết của User for (int i = 0; i < PieceOfTests.Count(); i++) { var tempUser = _UserManager.Get(PieceOfTests[i].UserId); PieceOfTests[i].User = new User { Avatar = tempUser.Avatar, FirstName = tempUser.FirstName, LastName = tempUser.LastName }; } // Tạo đối tượng phân trang ViewBag.Pagination = new Pagination(nameof(Index), NameUtils.ControllerName <TestController>()) { PageCurrent = page, Type = type, NumberPage = PaginationUtils.TotalPageCount( _PieceOfTestManager.StudentTestCountOfType( User.Id(), type.ToUpper().Trim(), searchKey, studentId, isUnRead ).ToInt(), Config.PAGE_PAGINATION_LIMIT ), Offset = Config.PAGE_PAGINATION_LIMIT }; // Lấy học viên nếu được chọn cụ thể if (studentId > 0) { ViewBag.Student = _UserManager.Get(studentId); } return(View(PieceOfTests)); }
private void AllExam_Load(object sender, EventArgs e) { if (Process.GetCurrentProcess().ProcessName != "devenv") { paginationUtils = new PaginationUtils(this.pnlPagination, this.custTipDialog, pageSizeCollection, QueryPaginationData, this.myOpaqueLayer); GetAllExamData(); } }
private void TeacherExamListForm_Load(object sender, EventArgs e) { paginationUtils = new PaginationUtils(this.pnlPagination, this.customTipDialog1, pageSizeCollection, QueryPaginationData, this.myOpaqueLayer); this.lblCurrentUser.Text = RememberUserParameter.username; if (Process.GetCurrentProcess().ProcessName != "devenv") { GetAllExamData(); } }
public IActionResult FindAll([FromQuery] PagingParameters pagingParameters) { pagingParameters.WithRoute(Request.Path.Value !); var allDevelopers = _developerService.FindAll().ToList(); var paginatedDevelopers = PaginationUtils.Paginate(allDevelopers, pagingParameters); var converted = PaginationUtils.ConvertItems(paginatedDevelopers, developer => developer.ToDto()); return(StatusCode(StatusCodes.Status200OK, converted)); }
public IActionResult FindAll([FromQuery] PagingParameters pagingParameters) { pagingParameters.WithRoute(Request.Path.Value !); var allProjects = _projectService.FindAll().ToList(); var paginatedProjects = PaginationUtils.Paginate(allProjects, pagingParameters); var converted = PaginationUtils.ConvertItems(paginatedProjects, project => project.ToDto()); return(StatusCode(StatusCodes.Status200OK, converted)); }
private void ExamDetailForm_Load(object sender, EventArgs e) { this.WindowState = FormPassValue.currentWindowState; paginationUtils = new PaginationUtils(this.pnlPagination, this.customTipDialog1, pageSizeCollection, QueryPaginationData, this.myOpaqueLayer); if (Process.GetCurrentProcess().ProcessName != "devenv") { GetAllExamData(); } }
public IActionResult Index( long topic = -1, int topicPage = 1, int vocabularyPage = 1, string topicSearchKey = "", string vocabularySearchKey = "") { #region For topic int topicStart = (topicPage - 1) * Config.PAGE_PAGINATION_LIMIT; var topics = _TopicManager.GetByPagination(topicStart, Config.PAGE_PAGINATION_LIMIT); ViewBag.Topics = topics; // Tạo đối tượng phân trang cho Category ViewBag.TopicPagination = new Pagination(nameof(Index), NameUtils.ControllerName <DictionaryManagerController>()) { PageKey = nameof(topicPage), PageCurrent = topicPage, NumberPage = PaginationUtils.TotalPageCount( _TopicManager.Count().ToInt(), Config.PAGE_PAGINATION_LIMIT), Offset = Config.PAGE_PAGINATION_LIMIT }; #endregion #region For vocabulary int vocabularyStart = (vocabularyPage - 1) * Config.PAGE_PAGINATION_LIMIT; int total = _VocabularyManager.CountFor(topic).ToInt(); // Tạo đối tượng phân trang cho Câu hỏi ViewBag.VocabularyPagination = new Pagination(nameof(Index), NameUtils.ControllerName <ReadingManagerController>()) { PageKey = nameof(vocabularyPage), PageCurrent = vocabularyPage, TypeKey = nameof(topic), Type = "0", NumberPage = PaginationUtils.TotalPageCount(total, Config.PAGE_PAGINATION_LIMIT), Offset = Config.PAGE_PAGINATION_LIMIT }; ViewBag.TopicName = _TopicManager.Get(topic)?.Name ?? ""; if (topic <= 0) { ViewBag.TopicName = "ALL"; } ViewBag.Vocabularies = _VocabularyManager.GetByPagination(topic, vocabularyStart, Config.PAGE_PAGINATION_LIMIT); #endregion return(View()); }
//[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] public async Task <IActionResult> GetAll([FromQuery] GetAllUsersQuery userFilterQuery, [FromQuery] PaginationQuery paginationQuery) { var paginationReq = _mapper.Map <PaginationRequest>(paginationQuery); var userFilter = _mapper.Map <GetAllPostsRequestFilter>(userFilterQuery); var users = await _usersService.GetUsers(paginationReq, userFilter); if (paginationReq == null || paginationReq.PageNumber < 1 || paginationReq.PageSize < 1) { return(Ok(new PagedResponse <UserResponse>(users))); } var paginatedResponse = PaginationUtils.BuildPaginatedResponse <UserResponse>(_uriService, paginationQuery, users); return(Ok(paginatedResponse)); }
public IActionResult GetDevelopers([FromRoute] Guid projectId, [FromQuery] PagingParameters pagingParameters) { var project = _projectService.FindById(projectId); if (project == null) { return(StatusCode(StatusCodes.Status404NotFound)); } pagingParameters.WithRoute(Request.Path.Value !); var filtered = project.DeveloperProjectRelations.Where(rel => rel.ProjectId.Equals(projectId)); var developers = filtered.Select(f => f.Developer); var paginated = PaginationUtils.Paginate(developers.ToList(), pagingParameters); return(StatusCode(StatusCodes.Status201Created, paginated)); }
public IActionResult YourOwnInstructor(int page = 1, string searchKey = "") { int start = (page - 1) * Config.PAGE_PAGINATION_LIMIT; long total = _PieceOfTestManager.CountAllInstructorOfStudent(User.Id()); IEnumerable <User> users = _UserManager.GetAllInstructorsOfStudent(User.Id(), start, Config.PAGE_PAGINATION_LIMIT); // Tạo đối tượng phân trang ViewBag.Pagination = new Pagination(nameof(Index), NameUtils.ControllerName <UserManagementController>()) { PageCurrent = page, NumberPage = PaginationUtils.TotalPageCount(total.ToInt(), Config.PAGE_PAGINATION_LIMIT), Offset = Config.PAGE_PAGINATION_LIMIT }; // Get data return(View(users)); }
public IActionResult Index(int page = 1, string searchKey = "") { // Lấy danh sách các cuộc thảo luận của người dùng hiện tại int start = (page - 1) * Config.PAGE_PAGINATION_LIMIT; var discussions = _DiscussionManager.GetByPaginationFor(User.Id(), start, Config.PAGE_PAGINATION_LIMIT); // Tạo đối tượng phân trang ViewBag.Pagination = new Pagination(nameof(Index), NameUtils.ControllerName <DiscussController>()) { PageCurrent = page, NumberPage = PaginationUtils.TotalPageCount( _DiscussionManager.CountAllFor(User.Id()).ToInt(), Config.PAGE_PAGINATION_LIMIT), Offset = Config.PAGE_PAGINATION_LIMIT }; return(View(discussions)); }
private IEnumerable <TestCategory> CategoryRender(string actionName, string typeCode, int partId, int categoryPage = 1, string categorySearchKey = "") { int categoryStart = (categoryPage - 1) * Config.PAGE_PAGINATION_LIMIT; var testCategories = _TestCategoryManager.GetByPagination(typeCode, partId, categoryStart, Config.PAGE_PAGINATION_LIMIT); // Tạo đối tượng phân trang cho Category ViewBag.CategoryPagination = new Pagination(actionName, NameUtils.ControllerName <SpeakingManagerController>()) { PageKey = nameof(categoryPage), PageCurrent = categoryPage, NumberPage = PaginationUtils.TotalPageCount( _TestCategoryManager.GetAll(typeCode, partId).Count(), Config.PAGE_PAGINATION_LIMIT), Offset = Config.PAGE_PAGINATION_LIMIT }; return(testCategories); }
public IActionResult Index( int notePage = 1, int noteId = -1) { // Lấy danh sách các ghi chú của User IEnumerable <UserNote> userNotes = _UserNoteManager.GetAll(User.Id()); // Tạo đối tượng phân trang cho Grammars ViewBag.NotePagination = new Pagination(nameof(Index), NameUtils.ControllerName <DictionaryController>()) { PageKey = nameof(notePage), PageCurrent = notePage, NumberPage = PaginationUtils.TotalPageCount( _UserNoteManager.CountFor(User.Id()), Math.Min(10, Config.PAGE_PAGINATION_LIMIT)), Offset = Math.Min(10, Config.PAGE_PAGINATION_LIMIT) }; return(View(userNotes)); }
public IActionResult Index(string type = "all", int page = 1, string searchKey = "") { int start = (page - 1) * Config.PAGE_PAGINATION_LIMIT; long allUserCount = _UserManager.Count(); long allLearnersCount = _UserManager.Count(UserType.ROLE_NORMAL_USER); long allManagersCount = _UserManager.Count(UserType.ROLE_MANAGER_USER) + _UserManager.Count(UserType.ROLE_MANAGER_LIBRARY) + _UserManager.Count(UserType.ROLE_ALL); long allBlockedCount = _UserManager.Count(null); if (searchKey != null && searchKey.Length > 0) { type = "all"; // Nếu có tìm, thì sẽ là tìm tất cả } ViewBag.AllUserCount = allUserCount; ViewBag.AllLearnersCount = allLearnersCount; ViewBag.AllManagersCount = allManagersCount; ViewBag.AllBlockedCount = allBlockedCount; long total; IEnumerable <User> users = new List <User>(); if (type.ToUpper() == "LEARNER".ToUpper()) { total = allLearnersCount; users = _UserManager.GetByPagination(start, Config.PAGE_PAGINATION_LIMIT, UserType.ROLE_NORMAL_USER); ViewBag.TableName = "LIST ALL LEARNERS"; ViewBag.TableDescription = "List all learners using your system"; } else if (type.ToUpper() == "MANAGER".ToUpper()) { total = allManagersCount; users = users .Concat(_UserManager.GetByPagination(start, Config.PAGE_PAGINATION_LIMIT, UserType.ROLE_ALL)) .Concat(_UserManager.GetByPagination(start, Config.PAGE_PAGINATION_LIMIT, UserType.ROLE_MANAGER_LIBRARY)) .Concat(_UserManager.GetByPagination(start, Config.PAGE_PAGINATION_LIMIT, UserType.ROLE_MANAGER_USER)).Distinct(); ViewBag.TableName = "LIST ALL MANAGER"; ViewBag.TableDescription = "List all manager of your system"; } else if (type.ToUpper() == "BLOCKED".ToUpper()) { total = allBlockedCount; users = _UserManager.GetByPagination(start, Config.PAGE_PAGINATION_LIMIT, null); ViewBag.TableName = "LIST ALL BLOCKED USERS"; ViewBag.TableDescription = "List all blocked user using your system"; } else { // ALL total = allUserCount; users = _UserManager.GetByPagination(searchKey, start, Config.PAGE_PAGINATION_LIMIT); if (searchKey != null && searchKey.Length > 0) { ViewBag.TableName = $"RESULT FOR \"{searchKey}\""; ViewBag.TableDescription = $"Match with {users.Count()} results"; } else { ViewBag.TableName = "LIST ALL USERS"; ViewBag.TableDescription = "List all user using your system"; } } // Tạo đối tượng phân trang ViewBag.Pagination = new Pagination(nameof(Index), NameUtils.ControllerName <UserManagementController>()) { PageCurrent = page, Type = type, NumberPage = PaginationUtils.TotalPageCount(total.ToInt(), Config.PAGE_PAGINATION_LIMIT), Offset = Config.PAGE_PAGINATION_LIMIT }; // Get data return(View(users)); }
public IActionResult Index(string type = "ALL", int page = 1, string searchKey = "", int instructorId = -1) { // Truyền gửi tên bảng if (type.ToUpper() == TestCategory.TEST_ALL) { ViewBag.TableName = "GENERAL"; } else { ViewBag.TableName = type.ToUpper(); } ViewBag.SearchKey = searchKey; // Lấy các đếm chuẩn ViewBag.UserTestCountOfAll = _PieceOfTestManager.UserTestCountOfType(User.Id(), "ALL", string.Empty, instructorId); ViewBag.UserTestCountOfListening = _PieceOfTestManager.UserTestCountOfType(User.Id(), TestCategory.LISTENING, string.Empty, instructorId); ViewBag.UserTestCountOfReading = _PieceOfTestManager.UserTestCountOfType(User.Id(), TestCategory.READING, string.Empty, instructorId); ViewBag.UserTestCountOfSpeaking = _PieceOfTestManager.UserTestCountOfType(User.Id(), TestCategory.SPEAKING, string.Empty, instructorId); ViewBag.UserTestCountOfWriting = _PieceOfTestManager.UserTestCountOfType(User.Id(), TestCategory.WRITING, string.Empty, instructorId); ViewBag.UserTestCountOfGeneral = _PieceOfTestManager.UserTestCountOfType(User.Id(), TestCategory.TEST_ALL, string.Empty, instructorId); // Tiến hành cấu hình phân trang int start = (page - 1) * Config.PAGE_PAGINATION_LIMIT; // Lấy danh sách IEnumerable <PieceOfTest> PieceOfTests = _PieceOfTestManager.GetByPagination(User.Id(), type, start, Config.PAGE_PAGINATION_LIMIT, searchKey, instructorId); // Tạo đối tượng phân trang ViewBag.Pagination = new Pagination(nameof(Index), NameUtils.ControllerName <TestController>()) { PageCurrent = page, Type = type, NumberPage = PaginationUtils.TotalPageCount( _PieceOfTestManager.UserTestCountOfType( User.Id(), type.ToUpper().Trim(), searchKey, instructorId ).ToInt(), Config.PAGE_PAGINATION_LIMIT ), Offset = Config.PAGE_PAGINATION_LIMIT }; // Lấy GVHD nếu có if (instructorId > 0) { ViewBag.Instructor = _UserManager.Get(instructorId); } if (type == "ALL") { type = string.Empty; } // Thực hiện phần thống kê nho nhỏ ViewBag.Passed = _PieceOfTestManager.PassedTestsCount(User.Id(), type); ViewBag.Failed = _PieceOfTestManager.FaildTestsCount(User.Id(), type); ViewBag.HighestScore = _PieceOfTestManager.HightestScore(User.Id(), type).ToScores(); return(View(PieceOfTests)); }
public IActionResult Part1( long category, int categoryPage = 1, int questionPage = 1, string categorySearchKey = "", string questionSearchKey = "") { int categoryStart = (categoryPage - 1) * Config.PAGE_PAGINATION_LIMIT; int questionStart = (questionPage - 1) * Config.PAGE_PAGINATION_LIMIT; var testCategories = _TestCategoryManager.GetByPagination(TestCategory.WRITING, 1, categoryStart, Config.PAGE_PAGINATION_LIMIT); ViewBag.TestCategories = testCategories; var quesitons = new List <WritingPartOne>(); if (category > 0) { var testCategory = _TestCategoryManager.Get(category); if (testCategory == null) { return(NotFound()); } else { ViewBag.QuestionType = testCategory.Name ?? ""; quesitons = _WritingPartOneManager.GetByPagination(category, questionStart, Config.PAGE_PAGINATION_LIMIT).ToList(); } } else { ViewBag.QuestionType = "ALL"; quesitons = _WritingPartOneManager.GetByPagination(questionStart, Config.PAGE_PAGINATION_LIMIT).ToList(); } ViewBag.Questions = quesitons; // Tạo đối tượng phân trang cho Category ViewBag.CategoryPagination = new Pagination(nameof(Part1), NameUtils.ControllerName <WritingManagerController>()) { PageKey = nameof(categoryPage), PageCurrent = categoryPage, NumberPage = PaginationUtils.TotalPageCount( _TestCategoryManager.GetAll(TestCategory.WRITING, 1).Count(), Config.PAGE_PAGINATION_LIMIT), Offset = Config.PAGE_PAGINATION_LIMIT }; var s = _WritingPartOneManager.CountAll(category.ToInt()); // Tạo đối tượng phân trang cho Reading Part 1 ViewBag.QuestionPagination = new Pagination(nameof(Part1), NameUtils.ControllerName <WritingManagerController>()) { PageKey = nameof(questionPage), PageCurrent = questionPage, TypeKey = nameof(category), Type = "0", NumberPage = PaginationUtils.TotalPageCount( _WritingPartOneManager.CountAll(category.ToInt()), Config.PAGE_PAGINATION_LIMIT), Offset = Config.PAGE_PAGINATION_LIMIT }; return(View($"{nameof(Part1)}/Index")); }