/// <summary> /// Prepare customer attribute value model /// </summary> /// <param name="model">Customer attribute value model</param> /// <param name="customerAttribute">Customer attribute</param> /// <param name="customerAttributeValue">Customer attribute value</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns>Customer attribute value model</returns> public virtual async Task <CustomerAttributeValueModel> PrepareCustomerAttributeValueModelAsync(CustomerAttributeValueModel model, CustomerAttribute customerAttribute, CustomerAttributeValue customerAttributeValue, bool excludeProperties = false) { if (customerAttribute == null) { throw new ArgumentNullException(nameof(customerAttribute)); } Action <CustomerAttributeValueLocalizedModel, int> localizedModelConfiguration = null; if (customerAttributeValue != null) { //fill in model values from the entity model ??= customerAttributeValue.ToModel <CustomerAttributeValueModel>(); //define localized model configuration action localizedModelConfiguration = async(locale, languageId) => { locale.Name = await _localizationService.GetLocalizedAsync(customerAttributeValue, entity => entity.Name, languageId, false, false); }; } model.CustomerAttributeId = customerAttribute.Id; //prepare localized models if (!excludeProperties) { model.Locales = await _localizedModelFactory.PrepareLocalizedModelsAsync(localizedModelConfiguration); } return(model); }
public virtual CustomerAttributeValueModel PrepareCustomerAttributeValueModel(CustomerAttributeValue customerAttributeValue) { var model = customerAttributeValue.ToModel(); return(model); }