/// <summary>
 /// Gets the APObject instance associated with this endpoint.
 /// </summary>
 /// <returns>The APObject associated with this endpoint.</returns>
 /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
 public async Task <APObject> GetObjectAsync(ApiOptions options = null)
 {
     if (this.Content != null)
     {
         return(this.Content);
     }
     else
     {
         return(await APObjects.GetAsync(this.Type, this.ObjectId, options : options));
     }
 }
Example #2
0
        /// <summary>
        /// Finds a paginated list of APDevices for the given type and search criteria.
        /// </summary>
        /// <param name="query">The search query</param>
        /// <param name="fields">The device specific fields to be retrieved.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="orderBy">The field on which to sort.</param>
        /// <param name="sortOrder">Sort order - Ascending or Descending.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>A paginated list of APDevice objects for the given search criteria.</returns>
        public async static Task <PagedList <APDevice> > FindAllAsync(IQuery query = null, IEnumerable <string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
        {
            var objects = await APObjects.FindAllAsync("device", query, fields, pageNumber, pageSize, orderBy, sortOrder, options);

            var devices = objects.Select(x => x as APDevice);
            var list    = new PagedList <APDevice>()
            {
                PageNumber   = objects.PageNumber,
                PageSize     = objects.PageSize,
                TotalRecords = objects.TotalRecords,
                GetNextPage  = async skip => await FindAllAsync(query, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
            };

            list.AddRange(devices);
            return(list);
        }
Example #3
0
 protected override async Task <Entity> FetchAsync(ApiOptions options = null)
 {
     return(await APObjects.GetAsync(this.Type, this.Id, options : options));
 }