Esempio n. 1
0
        /// <summary>
        /// Lazy load a service option entity to a DTO
        /// </summary>
        /// <param name="src">source entity</param>
        /// <returns></returns>
        public static IServiceOptionDto MapServiceOptionToDto(IServiceOption src)
        {
            if (src == null)
            {
                return(null);
            }

            Lazy <IServiceOptionDto> option = new Lazy <IServiceOptionDto>(() => new ServiceOptionDto
            {
                BusinessValue           = src.BusinessValue,
                Cost                    = src.Cost,
                Description             = src.Description,
                Details                 = src.Details,
                Id                      = src.Id,
                Included                = src.Included,
                Name                    = src.Name,
                Procurement             = src.Procurement,
                Picture                 = src.Picture,
                PriceMonthly            = src.PriceMonthly,
                PriceUpFront            = src.PriceUpFront,
                PictureMimeType         = src.PictureMimeType,
                Popularity              = src.Popularity,
                ServiceOptionCategoryId = src.ServiceOptionCategoryId,
                Utilization             = src.Utilization,
                BasicRequest            = src.BasicRequest,

                TextInputs              = new List <ITextInputDto>(),   /* lazy loading items later */
                SelectionInputs         = new List <ISelectionInputDto>(),
                ScriptedSelectionInputs = new List <IScriptedSelectionInputDto>()
            });

            // text inputs
            if (src.TextInputs != null)
            {
                foreach (var t in src.TextInputs)
                {
                    option.Value.TextInputs.Add(MapTextInputToDto(t));
                }
            }

            // selection inputs
            if (src.SelectionInputs != null)
            {
                foreach (var t in src.SelectionInputs)
                {
                    option.Value.SelectionInputs.Add(MapSelectionInputToDto(t));
                }
            }

            // scripted selection inputs
            if (src.ScriptedSelectionInputs != null)
            {
                foreach (var t in src.ScriptedSelectionInputs)
                {
                    option.Value.ScriptedSelectionInputs.Add(MapScriptedSelectionInputToDto(t));
                }
            }

            return(option.Value);
        }
 public ApplicationServiceOption(IServiceOption ServiceOption, IMapperOption MapperOption)
 {
     _serviceOption = ServiceOption;
     _mapperOption  = MapperOption;
 }