コード例 #1
0
        public async Task <IActionResult> ClientListData(Guid id, int skip, int take)
        {
            var integrationUid = id;

            if (integrationUid.IsEmptyGuid())
            {
                return(Forbid());
            }

            var request = new IntegrationClientReadListRequest(CurrentUser.Id, integrationUid);

            SetPaging(skip, take, request);
            var response = await _integrationService.GetIntegrationClients(request);

            if (response.Status.IsNotSuccess)
            {
                return(NotFound());
            }

            var result = new DataResult();

            result.AddHeaders("client_id", "client_secret", "is_active", "");

            for (var i = 0; i < response.Items.Count; i++)
            {
                var item = response.Items[i];
                var integrationClientRow = GetIntegrationClientRow(item, result);
                result.Data.Add(integrationClientRow);
            }

            result.PagingInfo      = response.PagingInfo;
            result.PagingInfo.Type = PagingInfo.PAGE_NUMBERS;

            return(Json(result));
        }
コード例 #2
0
        public async Task <IntegrationClientReadListResponse> GetIntegrationClients(IntegrationClientReadListRequest request)
        {
            var response = new IntegrationClientReadListResponse();

            var integration = await _integrationRepository.Select(x => x.Uid == request.IntegrationUid);

            if (integration.IsNotExist())
            {
                response.SetInvalidBecauseEntityNotFound();
                return(response);
            }

            var integrationId = integration.Id;
            Expression <Func <IntegrationClient, bool> >   filter        = x => x.IntegrationId == integrationId;
            Expression <Func <IntegrationClient, object> > orderByColumn = x => x.Id;

            if (request.SearchTerm.IsNotEmpty())
            {
                filter = x => x.IntegrationId == integrationId && x.Name.Contains(request.SearchTerm);
            }

            List <IntegrationClient> entities;

            if (request.PagingInfo.Skip < 1)
            {
                entities = await _integrationClientRepository.SelectAfter(filter, request.PagingInfo.LastUid, request.PagingInfo.Take, orderByColumn, request.PagingInfo.IsAscending);
            }
            else
            {
                entities = await _integrationClientRepository.SelectMany(filter, request.PagingInfo.Skip, request.PagingInfo.Take, orderByColumn, request.PagingInfo.IsAscending);
            }

            if (entities != null)
            {
                for (var i = 0; i < entities.Count; i++)
                {
                    var entity = entities[i];
                    var dto    = _integrationClientFactory.CreateDtoFromEntity(entity);
                    response.Items.Add(dto);
                }
            }

            response.PagingInfo.Skip           = request.PagingInfo.Skip;
            response.PagingInfo.Take           = request.PagingInfo.Take;
            response.PagingInfo.LastUid        = request.PagingInfo.LastUid;
            response.PagingInfo.IsAscending    = request.PagingInfo.IsAscending;
            response.PagingInfo.TotalItemCount = await _integrationClientRepository.Count(filter);

            response.Status = ResponseStatus.Success;
            return(response);
        }
コード例 #3
0
        public static IntegrationClientReadListRequest GetIntegrationClientReadListRequest()
        {
            var request = new IntegrationClientReadListRequest(CurrentUserId, UidOne);

            return(request);
        }