Exemplo n.º 1
0
        public async Task GetPageDataTest()
        {
            var mockSet     = new Mock <DbSet <Role> >().SetupList(_sampleList);
            var mockContext = new Mock <LiveShowDBContext>();

            mockContext.Setup(x => x.Role).Returns(mockSet.Object);
            var mockSvc = new RoleSvc(mockContext.Object);
            var result  = await mockSvc.GetPageDataAsync(new RoleQueryModel());

            Assert.Equal(_sampleList.Count(), result.List.Count());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetPageData(int pageIndex = 1, int pageDataCount = 10)
        {
            var roles = await RoleSvc.GetPageDataAsync(pageIndex, pageDataCount);

            var totalCount = await RoleSvc.TotalCountAsync();

            return(new JsonResult(new APIResult <ListModel <ListRolePermissionDTO> > {
                Data = new ListModel <ListRolePermissionDTO> {
                    Datas = roles, TotalCount = totalCount
                }
            }));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> List(int pageIndex = 1, int pageDataCount = 10)
        {
            var model = await RoleSvc.GetPageDataAsync(pageIndex, pageDataCount);

            if (model == null)
            {
                return(Content(RoleSvc.ErrorMsg));
            }
            NoRainPage page = new NoRainPage();

            page.DataCount   = model.TotalCount;
            page.PageIndex   = pageIndex;
            page.Url         = "/role/List?pageIndex=@parms";
            ViewData["Page"] = page.GetPaging();
            return(View(model));
        }