Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // register db contexts
            string conString = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <BaseContext <Note> >(opt => opt.UseSqlServer(conString));

            // register repositories
            services.AddTransient <IBaseRepository <Note>, BaseRepository <Note> >();
            services.AddTransient <INoteService, NoteService>();

            // register identity server
            services.AddIdentityServer()
            .AddInMemoryClients(Clients.Get())
            .AddInMemoryIdentityResources(Resources.GetIdentityResources())
            .AddInMemoryApiResources(Resources.GetApiResources())
            .AddTestUsers(Users.Get())
            .AddSigningCredential(CertHelper.GetDevCertificate());

            // register automapper
            AutoMapperConfig.ConfigAutoMapper(services);
            services.AddMvc();
        }