Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddSingleton <IDocumentDBConnection>(x =>
                                                          CosmosDBDefinitions.GetConnection()
                                                          );

            services.AddTransient <VehiclesRepository>(x =>
                                                       new VehiclesRepository(
                                                           x.GetService <IDocumentDBConnection>()
                                                           ));
            services.AddMvc();
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            // Add application services.
            services.AddTransient <IEmailSender, EmailSender>();
            services.AddSingleton <IDocumentDBConnection>(x =>
                                                          CosmosDBDefinitions.GetConnection()
                                                          );
            services.AddTransient <ToDoItemsRepository>(x =>
                                                        new ToDoItemsRepository(
                                                            x.GetService <IDocumentDBConnection>(),
                                                            x.GetService <IHttpContextAccessor>()
                                                            .HttpContext?.User?.Identity?.Name
                                                            ));
            services.AddMvc();
        }