Пример #1
0
 public static DeliveryDateModel ToModel(this DeliveryDate entity)
 {
     return(entity.MapTo <DeliveryDate, DeliveryDateModel>());
 }
Пример #2
0
 public static DeliveryDate ToEntity(this DeliveryDateModel model, DeliveryDate destination)
 {
     return(model.MapTo(destination));
 }
Пример #3
0
        /// <summary>
        /// Prepare delivery date model
        /// </summary>
        /// <param name="model">Delivery date model</param>
        /// <param name="deliveryDate">Delivery date</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Delivery date model</returns>
        public virtual DeliveryDateModel PrepareDeliveryDateModel(DeliveryDateModel model, DeliveryDate deliveryDate, bool excludeProperties = false)
        {
            Action <DeliveryDateLocalizedModel, int> localizedModelConfiguration = null;

            if (deliveryDate != null)
            {
                //fill in model values from the entity
                model = model ?? deliveryDate.ToModel <DeliveryDateModel>();

                //define localized model configuration action
                localizedModelConfiguration = (locale, languageId) =>
                {
                    locale.Name = _localizationService.GetLocalized(deliveryDate, entity => entity.Name, languageId, false, false);
                };
            }

            //prepare localized models
            if (!excludeProperties)
            {
                model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration);
            }

            return(model);
        }