try
{
// For sake of brevity the jobsite parentGuid was omitted here
var avontusModel = Avontus.Rental.Library.StockingLocation.NewStockingLocation(Avontus.Rental.Library.PartnerTypes.JobSite, Guid.Empty);
// ... Populate the address field for one of the following scenarios
// The following scenarios do not have messages included in the validationException object when attempting to save
// NOTE: PCG has confirmed this issue existts for StockingLocation and
// Business, Billing and Shipping address 1 is not validated as required when there is a non-whitespace value for one of the other corresponding address fields
// Business, Billing and Shipping address 1, 2, 3 and 4 are not validated to the maximum of 50 characters
// Business, Billing and Shipping city is not validated as required when there is a non-whitespace value for one of the other corresponding address fields
// Business, Billing and Shipping city is not validated to the maximum of 50 characters
// Business, Billing and Shipping state is not validated as required when there is a non-whitespace value for one of the other corresponding address fields
// Business, Billing and Shipping postal code is not validated as required when there is a non-whitespace for one of the corresponding address fields
// Avontus recommends calling ApplyEdit() then Save() for business objects here!
// REF: https://quantifyapi.avontus.com/t/updating-product-totals-for-a-job-site/361/8
// This prepares an Avonus object for a commit using the ApplyEdit method
var supportUndo = avontusModel as Avontus.Core.Core.ISupportUndo;
if (supportUndo == null) throw new NotSupportedException("avontusModel does not support the Avontus.Core.Core.ISupportUndo interface");
supportUndo.ApplyEdit();
// This attempts to save the object to the Avontus database through the Avontus API layer using the Save method.
var savable = avontusModel as Avontus.Core.Core.ISavable;
if (savable == null) throw new NotSupportedException("avontusModel does not support the Avontus.Core.Core.ISavable interface");
savable.Save();
}
catch (Avontus.Core.Validation.ValidationException validationException)
{
// Notice the avontusModel does not include any validations related to address field scenarios above
}
Hello Brandon.
For Address, the validations at the API level, currently are limited to String-Max-Length rules for the properties.
try
{
var branch = StockingLocation.NewStockingLocation(PartnerTypes.BranchOffice, Guid.Empty);
branch.Name = "Test Branch 1";
branch.ParentTradingPartnerID = parentID;
var businessAddress = branch.Addresses.GetAddressByType(AddressTypes.Business);
businessAddress.Street = "12345678901234567890123456789012345678901234501234567890";
branch.Save();
}
catch (Avontus.Core.Validation.ValidationException)
{
}