public void UpdateInvoice_NullableProperties(int invoiceId) { // Entity's properties which can be null are of NullableProperty<T> type in order to distinguish // between non-changing the property value and explicit setting to null. var secondRow = new IssuedInvoiceItemPatchModel { Id = GetSecondRowId(invoiceId) }; // At this point, properties DiscountPercentage, PriceListItemId and VatCodeId wouldn't be changed in iDoklad - their IsSet // property contains false. // Explicit set VatCodeId of last row to null - no explicit conversion to NullableProperty<int> needed. secondRow.VatCodeId = null; // Set DiscountPercentage to 10% - no explicit conversion to NullableProperty<decimal> needed. secondRow.DiscountPercentage = 10m; // In some cases, explicit conversion is required to determine the type of expression result. // Set specific value or null - DiscountPercentage in iDoklad will be changed secondRow.DiscountPercentage = DateTime.Today.DayOfWeek == DayOfWeek.Friday ? (NullableProperty <decimal>) 5 : null; secondRow.DiscountPercentage = DateTime.Today.DayOfWeek == DayOfWeek.Sunday ? new NullableProperty <decimal>(10) : null; // Preserve original value in iDoklad - DiscountPercentage in iDoklad won't be changed secondRow.DiscountPercentage = default; // Property value can be accessed by its Value property or we can use implicit conversion. var discountPercentage1 = secondRow.DiscountPercentage.Value; decimal?discountPercentage2 = secondRow.DiscountPercentage; // Create update model for first row. If we didn't include it in invoice update model, it would be removed. var firstRow = new IssuedInvoiceItemPatchModel { Id = GetFirstRowId(invoiceId) }; // Create invoice update model. var invoiceUpdateModel = new IssuedInvoicePatchModel { Id = invoiceId, Items = new List <IssuedInvoiceItemPatchModel> { firstRow, secondRow } }; // Update the invoice var updatedInvoice = _api.IssuedInvoiceClient.Update(invoiceUpdateModel).Data; }
public async Task UpdateAsync_SuccessfullyUpdated() { var model = new IssuedInvoicePatchModel { Id = _issuedInvoiceIdAsync, Description = "DescriptionUpdated" }; // Act var data = (await _issuedInvoiceClient.UpdateAsync(model)).AssertResult(); // Assert Assert.AreEqual(model.Description, data.Description); }
public void UpdateInvoice_AddItemFromPriceList(int invoiceId, int priceListItemId) { // Create update model containing id (required) and only properties to be updated. // Update first invoice item's amount and add new invoice item containing price list item. var invoiceUpdateModel = new IssuedInvoicePatchModel { Id = invoiceId, Description = "Updated invoice", Items = new List <IssuedInvoiceItemPatchModel> { new IssuedInvoiceItemPatchModel { Id = GetFirstRowId(invoiceId), Amount = 5 }, AddPriceListItem(priceListItemId, 2) } }; // Update the invoice var updatedInvoice = _api.IssuedInvoiceClient.Update(invoiceUpdateModel).Data; }
public void Update_SuccessfullyUpdated() { var model = new IssuedInvoicePatchModel { Id = _issuedInvoiceId, Description = "DescriptionUpdated", DeliveryAddressId = DeliveryAddressId2, MyAddress = new MyDocumentAddressPatchModel { AccountNumber = "555777", Iban = "5453187522" } }; // Act var data = _issuedInvoiceClient.Update(model).AssertResult(); // Assert Assert.AreEqual(model.Description, data.Description); Assert.AreEqual(model.MyAddress.AccountNumber, data.MyAddress.AccountNumber); Assert.AreEqual(model.MyAddress.Iban, data.MyAddress.Iban); AssertDeliveryAddress(data.DeliveryAddress, DeliveryAddressId2); }
/// <inheritdoc /> public ApiResult <IssuedInvoiceGetModel> Update(IssuedInvoicePatchModel model) { return(Patch <IssuedInvoicePatchModel, IssuedInvoiceGetModel>(model)); }
/// <inheritdoc /> public Task <ApiResult <IssuedInvoiceGetModel> > UpdateAsync(IssuedInvoicePatchModel model, CancellationToken cancellationToken = default) { return(PatchAsync <IssuedInvoicePatchModel, IssuedInvoiceGetModel>(model, cancellationToken)); }