Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            IdentityModule.RegisterIdentity(services);
            ServiceModule.InitIoC(services, Configuration.GetConnectionString("BankSystemDb"));
            InitializeIoC.Init(services);

            //Register Mapper
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new ServiceMapper());
                cfg.AddProfile(new SecurityMapper());
                cfg.AddProfile(new ViewModelMapper());
            });

            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);
            //
            services.AddSession();
            services.AddMvc();

            // Add application services.
            services.AddTransient <IEmailSender, AuthMessageSender>();
            services.AddTransient <ISmsSender, AuthMessageSender>();

            //app settings
            var appSettings = Configuration.GetSection("AppSettings");

            services.Configure <AppSettings>(appSettings);

            //filters
            services.AddScoped <AccountFilter>();
            services.AddScoped <TransactionFilter>();
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            AddWebApi(services);
            InitializeIoC.RegisterAll(services, ConnectionString);
            services.AddCors(o =>
            {
                o.AddPolicy("AllowAll", policyBuilder =>
                {
                    policyBuilder.AllowAnyMethod()
                    .AllowAnyHeader()
                    .AllowCredentials();

                    policyBuilder.WithOrigins("http://localhost:4200");
                });
            });
        }