/// <summary> /// Sets asynchronously the expense payment status. /// </summary> /// <param name="id">The expense id.</param> /// <param name="status">The new payment status.</param> /// <param name="effectiveDate">The date when payment was performed.</param> public async Task SetPaymentStatusAsync(int id, ExpensePaymentStatus status, DateTime effectiveDate) { if (id < 1) { throw new ArgumentOutOfRangeException(nameof(id), "Value must be greater than zero."); } // Get url string urlFormat; switch (status) { case ExpensePaymentStatus.Paid: urlFormat = "expenses/{0}/fire.json?event=pay&paid_at=" + Uri.EscapeDataString(XmlConvert.ToString(effectiveDate, XmlDateTimeSerializationMode.RoundtripKind)); break; default: urlFormat = "expenses/{0}/fire.json?event=remove_payment"; break; } var c = this.Context.GetHttpClient(); var r = await c.PostAsync(string.Format(urlFormat, id), new StringContent(string.Empty)); r.EnsureFakturoidSuccess(); }
/// <summary> /// Sets the expense payment status. /// </summary> /// <param name="id">The expense id.</param> /// <param name="status">The new payment status.</param> /// <param name="effectiveDate">The date when payment was performed.</param> public void SetPaymentStatus(int id, ExpensePaymentStatus status, DateTime effectiveDate) { try { this.SetPaymentStatusAsync(id, status, effectiveDate).Wait(); } catch (AggregateException aex) { throw aex.InnerException; } }
/// <summary> /// Sets asynchronously the expense payment status. /// </summary> /// <param name="id">The expense id.</param> /// <param name="status">The new payment status.</param> /// <returns>Instance of <see cref="JsonExpense"/> class with modified entity.</returns> public async Task SetPaymentStatusAsync(int id, ExpensePaymentStatus status) { await this.SetPaymentStatusAsync(id, status, DateTime.Now); }
/// <summary> /// Sets the expense payment status. /// </summary> /// <param name="id">The expense id.</param> /// <param name="status">The new payment status.</param> public void SetPaymentStatus(int id, ExpensePaymentStatus status) { this.SetPaymentStatus(id, status, DateTime.Now); }