/// <summary> /// Prepare address attribute model /// </summary> /// <param name="model">Address attribute model</param> /// <param name="addressAttribute">Address attribute</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns> /// A task that represents the asynchronous operation /// The task result contains the address attribute model /// </returns> public virtual async Task <AddressAttributeModel> PrepareAddressAttributeModelAsync(AddressAttributeModel model, AddressAttribute addressAttribute, bool excludeProperties = false) { Action <AddressAttributeLocalizedModel, int> localizedModelConfiguration = null; if (addressAttribute != null) { //fill in model values from the entity model ??= addressAttribute.ToModel <AddressAttributeModel>(); //prepare nested search model PrepareAddressAttributeValueSearchModel(model.AddressAttributeValueSearchModel, addressAttribute); //define localized model configuration action localizedModelConfiguration = async(locale, languageId) => { locale.Name = await _localizationService.GetLocalizedAsync(addressAttribute, entity => entity.Name, languageId, false, false); }; } //prepare localized models if (!excludeProperties) { model.Locales = await _localizedModelFactory.PrepareLocalizedModelsAsync(localizedModelConfiguration); } return(model); }
public virtual AddressAttributeModel PrepareAddressAttributeModel(AddressAttribute addressAttribute) { var model = addressAttribute.ToModel(); return(model); }