/// <summary> /// Gets paged list of invoices. /// </summary> /// <param name="page">The page number.</param> /// <param name="status">The expense status.</param> /// <param name="subjectId">The customer subject id.</param> /// <param name="since">The date since when the expense was created.</param> /// <param name="number">The expense display number.</param> /// <returns> /// List of <see cref="JsonExpense" /> instances. /// </returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// page;Value must be greater than zero. /// or /// subjectId;Value must be greater than zero. /// </exception> public IEnumerable <JsonExpense> Select(int page, ExpenseStatusCondition status = ExpenseStatusCondition.Any, int?subjectId = null, DateTime?since = null, string number = null) { try { return(this.SelectAsync(page, status, subjectId, since, number).Result); } catch (AggregateException aex) { throw aex.InnerException; } }
/// <summary> /// Gets asynchronously paged list of invoices. /// </summary> /// <param name="page">The page number.</param> /// <param name="status">The expense status.</param> /// <param name="subjectId">The customer subject id.</param> /// <param name="since">The date since when the expense was created.</param> /// <param name="number">The expense display number.</param> /// <returns> /// List of <see cref="JsonExpense" /> instances. /// </returns> /// <exception cref="System.ArgumentOutOfRangeException"> /// page;Value must be greater than zero. /// or /// subjectId;Value must be greater than zero. /// </exception> public async Task <IEnumerable <JsonExpense> > SelectAsync(int page, ExpenseStatusCondition status = ExpenseStatusCondition.Any, int?subjectId = null, DateTime?since = null, string number = null) { if (page < 1) { throw new ArgumentOutOfRangeException(nameof(page), "Value must be greater than zero."); } if (subjectId.HasValue && subjectId.Value < 1) { throw new ArgumentOutOfRangeException(nameof(subjectId), "Value must be greater than zero."); } // Get URI based on expense type string uri = CollectionPath; // Get status string based string statusString = null; switch (status) { case ExpenseStatusCondition.Open: statusString = "open"; break; case ExpenseStatusCondition.Overdue: statusString = "overdue"; break; case ExpenseStatusCondition.Paid: statusString = "paid"; break; } // Prepare query parameters var queryParams = new { status = statusString, subject_id = subjectId.HasValue ? subjectId.Value.ToString() : null, since = since, number = number }; // Get entities return(await base.GetPagedEntitiesAsync <JsonExpense>(uri, page)); }