Beispiel #1
0
        protected async override Task <bool> GetDataAsync()
        {
            var entityResource = new EntityResource(Context);

            if (String.IsNullOrEmpty(ListName) || (!ListName.Contains("@") && String.IsNullOrEmpty(Namespace)))
            {
                throw new Exception("ListName or Namespace is missing");
            }
            var fqn = ListName;

            if (!ListName.Contains("@"))
            {
                fqn = ListName + "@" + Namespace;
            }

            var entities = await entityResource.GetEntitiesAsync(fqn, PageSize, StartIndex, Filter, SortBy, ResponseFields);

            _results = new EntityCollection <T>
            {
                PageCount  = entities.PageCount,
                PageSize   = entities.PageSize,
                StartIndex = entities.StartIndex,
                TotalCount = entities.TotalCount
            };

            _results.Items = entities.Items.ConvertAll(JObjectConverter <T>);

            TotalCount = _results.TotalCount;
            PageCount  = _results.PageCount;
            PageSize   = _results.PageSize;
            return(_results.Items != null && _results.Items.Count > 0);
        }
        public async Task <IEnumerable <AppLog> > List(int tenantId, int?pageSize, int?startIndex, string sortBy)
        {
            var apiContext     = new ApiContext(tenantId);
            var entityResource = new EntityResource(apiContext);
            var entities       = await entityResource.GetEntitiesAsync(_listFullName, pageSize, startIndex, sortBy : sortBy);

            return(entities.Items.ConvertAll(ToAppLogConverter));
        }
        public async Task <EntityCollection <T> > GetEntitiesAsync <T>(IApiContext apiContext, string listName, int?pageSize, int?startIndex, string filter, string sortBy, string responseFileds)
        {
            var entityResource = new EntityResource(apiContext);
            var listFQN        = ValidateListName(listName);
            var entities       = await entityResource.GetEntitiesAsync(listFQN, pageSize, startIndex, filter, sortBy, responseFileds);

            var entityCollection = new EntityCollection <T>
            {
                PageCount  = entities.PageCount,
                PageSize   = entities.PageSize,
                StartIndex = entities.StartIndex,
                TotalCount = entities.TotalCount
            };

            entityCollection.Items = entities.Items.ConvertAll(JObjectConverter <T>);

            return(entityCollection);
        }