Try your search with a different keyword or use * as a wildcard.
using Nop.Core.Domain.Common;
using Nop.Services.Attributes;
using Nop.Web.Areas.Admin.Models.Common;
namespace Nop.Web.Areas.Admin.Factories;
///
/// Represents the address model factory implementation
///
public partial class AddressModelFactory : IAddressModelFactory
{
#region Fields
protected readonly IAddressAttributeModelFactory _addressAttributeModelFactory;
protected readonly IAttributeFormatter _addressAttributeFormatter;
protected readonly IBaseAdminModelFactory _baseAdminModelFactory;
#endregion
#region Ctor
public AddressModelFactory(IAddressAttributeModelFactory addressAttributeModelFactory,
IAttributeFormatter addressAttributeFormatter,
IBaseAdminModelFactory baseAdminModelFactory)
{
_addressAttributeModelFactory = addressAttributeModelFactory;
_addressAttributeFormatter = addressAttributeFormatter;
_baseAdminModelFactory = baseAdminModelFactory;
}
#endregion
#region Methods
///
/// Prepare address model
///
/// Address model
/// Address
/// A task that represents the asynchronous operation
public virtual async Task PrepareAddressModelAsync(AddressModel model, Address address = null)
{
ArgumentNullException.ThrowIfNull(model);
//prepare available countries
await _baseAdminModelFactory.PrepareCountriesAsync(model.AvailableCountries);
//prepare available states
await _baseAdminModelFactory.PrepareStatesAndProvincesAsync(model.AvailableStates, model.CountryId);
//prepare custom address attributes
await _addressAttributeModelFactory.PrepareCustomAddressAttributesAsync(model.CustomAddressAttributes, address);
if (address == null)
return;
model.FormattedCustomAddressAttributes = await _addressAttributeFormatter.FormatAttributesAsync(address.CustomAttributes);
}
#endregion
}