예제 #1
0
        public DataResult <bool> UpdateNames(
            ExternalLoginProviderModel externalLoginProvider,
            DynamicModuleModel dynamicModule,
            Type moduleInfoModuleConfigType
            )
        {
            var dynamicModuleConfiguration = dynamicModule.Configuration(moduleInfoModuleConfigType);

            if (string.IsNullOrEmpty(dynamicModuleConfiguration.Name))
            {
                var message = $"Property '{nameof(dynamicModuleConfiguration.Name)}' is required";

                m_logger.LogWarning(message);
                return(Error <bool>(message));
            }

            if (string.IsNullOrEmpty(dynamicModuleConfiguration.DisplayName))
            {
                var message = $"Property '{nameof(dynamicModuleConfiguration.DisplayName)}' is required";

                m_logger.LogWarning(message);
                return(Error <bool>(message));
            }

            try
            {
                return(Success(
                           m_externalLoginProviderUoW.UpdateNames(
                               externalLoginProvider.Id,
                               dynamicModuleConfiguration.Name,
                               dynamicModuleConfiguration.DisplayName
                               )
                           ));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <bool>(e.Message));
            }
        }
예제 #2
0
        public DataResult <int> CreateDynamicModule(
            DynamicModuleModel dynamicModuleModel,
            ILibModuleInfo dynamicModuleInfo
            )
        {
            var dynamicModuleEntity = new DynamicModuleEntity
            {
                ModuleGuid           = dynamicModuleModel.ModuleGuid,
                Name                 = dynamicModuleModel.Name,
                ConfigurationVersion = dynamicModuleInfo.Version
            };

            try
            {
                var result = m_dynamicModuleUoW.CreateDynamicModule(dynamicModuleEntity);
                return(Success(result));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <int>(e.Message));
            }
        }
예제 #3
0
        public DataResult <int> CreateExternalLoginByDynamicModule(DynamicModuleModel dynamicModule, Type dynamicModuleType)
        {
            var mainLogo = dynamicModule.DynamicModuleBlobs.FirstOrDefault(
                x => x.Type == DynamicModuleBlobEnumModel.MainLogo
                );

            if (mainLogo == null)
            {
                var message =
                    $"Unable to create {nameof(ExternalLoginProviderEntity)} without {nameof(DynamicModuleBlobEnumModel.MainLogo)}";

                m_logger.LogWarning(message);
                return(Error <int>(message));
            }

            var externalLoginProviderEntity = new ExternalLoginProviderEntity
            {
                Name        = dynamicModule.Name,
                DisplayName = dynamicModule.Configuration(dynamicModuleType).DisplayName ?? dynamicModule.Name,
            };

            try
            {
                return(Success(
                           m_externalLoginProviderUoW.CreateExternalLoginByDynamicModule(
                               dynamicModule.Id,
                               externalLoginProviderEntity,
                               mainLogo.File.Id
                               )
                           ));
            }
            catch (DatabaseException e)
            {
                m_logger.LogWarning(e);
                return(Error <int>(e.Message));
            }
        }
예제 #4
0
        private void SynchronizeMainLogo(ExternalLoginProviderModel externalLoginProvider, DynamicModuleModel dynamicModule)
        {
            var dynamicModuleMainLogo = dynamicModule.DynamicModuleBlobs.FirstOrDefault(
                x => x.Type == DynamicModuleBlobEnumModel.MainLogo
                );

            if (dynamicModuleMainLogo != null)
            {
                m_externalLoginProviderManager.UpdateLogo(externalLoginProvider, dynamicModuleMainLogo.File);
            }
        }
예제 #5
0
 public DataResult <bool> UpdateDynamicModule(ExternalLoginProviderModel externalLoginProvider, DynamicModuleModel dynamicModule)
 {
     try
     {
         return(Success(
                    m_externalLoginProviderUoW.UpdateDynamicModule(
                        externalLoginProvider.Id,
                        dynamicModule.Id
                        )
                    ));
     }
     catch (DatabaseException e)
     {
         m_logger.LogWarning(e);
         return(Error <bool>(e.Message));
     }
 }
예제 #6
0
 public DataResult <ExternalLoginProviderModel> GetExternalLoginProvidersByDynamicModule(DynamicModuleModel dynamicModule)
 {
     try
     {
         var externalLoginProvider = m_externalLoginProviderUoW.GetExternalLoginProvidersByDynamicModule(dynamicModule.Id);
         return(Success(
                    m_mapper.Map <ExternalLoginProviderModel>(externalLoginProvider)
                    ));
     }
     catch (DatabaseException e)
     {
         m_logger.LogWarning(e);
         return(Error <ExternalLoginProviderModel>(e.Message));
     }
 }