public async Task <IActionResult> GetAsync([FromQuery] Paging paging)
        {
            var permission = await _workcontext.GetContextAsync(nameof(CorePolicy.OrganizationPolicy.OrganizationUnit_Read));

            var repo  = _uow.GetRepository <IOrganizationUnitRepository>();
            var paged = await repo.PagingAsync(permission, paging);

            var result = new Paged <OrganizationUnitModel>
            {
                Data       = paged.Data.Select(x => (OrganizationUnitModel)x),
                Page       = paged.Page,
                Q          = paged.Q,
                Size       = paged.Size,
                TotalItems = paged.TotalItems,
                TotalPages = paged.TotalPages
            };

            return(Ok(result));
        }
Beispiel #2
0
        public async Task <IActionResult> GetAsync([FromQuery] Paging paging)
        {
            var context = await _workcontext.GetContextAsync(nameof(CorePolicy.LabelPolicy.Label_Read));

            var repo  = _uow.GetRepository <ILabelRepository>();
            var paged = await repo.PagingAsync(context, paging);

            var result = new Paged <LabelModel>
            {
                Data       = paged.Data.Select(x => (LabelModel)x),
                Page       = paged.Page,
                Q          = paged.Q,
                Size       = paged.Size,
                TotalItems = paged.TotalItems,
                TotalPages = paged.TotalPages
            };

            return(Ok(result));
        }
Beispiel #3
0
        public async Task <IActionResult> GetAsync([FromQuery] Paging paging)
        {
            var context = await _workcontext.GetContextAsync(nameof(CorePolicy.UserPolicy.User_Read));

            var repoUser = _uow.GetRepository <IUserRepository>();
            var paged    = await repoUser.PagingAsync(context, paging);

            var userCodes = paged.Data.Select(x => x.Id).ToList();

            var repoUserInfo = _uow.GetRepository <IUserRepository>();
            var infos        = (await repoUserInfo.FindInfoByIdsAsync(userCodes)).ToDictionary(x => x.Id, x => x);

            var users = new List <UserModel>();

            foreach (var data in paged.Data)
            {
                UserModel user = data;
                if (infos.ContainsKey(data.Id))
                {
                    user.Infos = infos[data.Id];
                }
                users.Add(user);
            }

            var result = new Paged <UserModel>
            {
                Data       = users,
                Page       = paged.Page,
                Q          = paged.Q,
                Size       = paged.Size,
                TotalItems = paged.TotalItems,
                TotalPages = paged.TotalPages
            };

            return(Ok(result));
        }