public GroupedConfigMappings(IStoredConfigAsService storedConfigAsService, IYuzuConfiguration config, IYuzuDeliveryImportConfiguration importConfig, IVmGetterService vmGetterService)
        {
            var groupedConfigs = storedConfigAsService.GetAll <GroupStoreContentAs>();

            foreach (var group in groupedConfigs)
            {
                var vmName            = group.Key;
                var documentTypeAlias = group.Value.DocumentTypeAlias;
                var groupSettings     = group.Value.StoreContentAs.As <GroupStoreContentAs>();

                var groupName = group.Value.StoreContentAs.GroupName;
                if (string.IsNullOrEmpty(groupName))
                {
                    groupName = importConfig.DefaultPropertyGroup;
                }

                var parentPropertyName = groupSettings.ParentPropertyName;

                var sourceType = config.CMSModels.Where(x => x.Name.ToLower() == documentTypeAlias.ToLower()).FirstOrDefault();
                var destParent = config.ViewModels.Where(x => x.Name == groupSettings.ParentPropertyType).FirstOrDefault();
                var destChild  = config.ViewModels.Where(x => x.Name == vmName).FirstOrDefault();

                if (sourceType != null && destParent != null && destChild != null)
                {
                    ManualMaps.AddGroup(sourceType, destParent, destChild, parentPropertyName, groupName);
                }
            }
        }
예제 #2
0
        public GlobalConfigMappings(IStoredConfigAsService storedConfigAsService, IYuzuConfiguration config, IYuzuDeliveryImportConfiguration importConfig, IVmHelperService vmHelperService)
        {
            var globalConfigs = storedConfigAsService.GetAll <GlobalStoreContentAs>();

            foreach (var global in globalConfigs)
            {
                var vmName = global.Key;

                var documentTypeAlias = global.Value.DocumentTypeAlias;
                if (string.IsNullOrEmpty(documentTypeAlias))
                {
                    documentTypeAlias = vmHelperService.Get(vmName).ContentType.Alias;
                }

                var groupName = global.Value.StoreContentAs.GroupName;

                var sourceType = config.CMSModels.Where(x => x.Name.ToLower() == documentTypeAlias.ToLower()).FirstOrDefault();
                var dest       = config.ViewModels.Where(x => x.Name == vmName).FirstOrDefault();

                if (sourceType != null && dest != null)
                {
                    ManualMaps.AddGlobal(sourceType, dest, groupName);
                }
            }
        }