예제 #1
0
        public static AppSettings ConfigureBusinessServices(this IServiceCollection services, IConfiguration configuration)
        {
            var appSettingsSection = configuration.GetSection(nameof(AppSettings));

            if (appSettingsSection == null)
            {
                throw new System.Exception("No appsettings section has been found");
            }

            var appSettings = appSettingsSection.Get <AppSettings>();

            if (!appSettings.IsValid())
            {
                throw new Exception("No valid settings.");
            }

            services.Configure <AppSettings>(appSettingsSection);

            //Automap settings
            services.AddAutoMapper();
            MappingConfigurationsHelper.ConfigureMapper();

            services.AddTransient <IUserService, UserService>();

            return(appSettings);
        }
예제 #2
0
 public static void ConfigureMappings(this IServiceCollection services)
 {
     if (services != null)
     {
         //Automap settings
         services.AddAutoMapper(Assembly.GetExecutingAssembly());
         MappingConfigurationsHelper.ConfigureMapper();
     }
 }