// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { // Add Entity Framework services to the services container. services.AddEntityFramework() .AddSqlServer() .AddDbContext <PhotoGalleryContext>(options => options.UseSqlServer(Configuration["Data:PhotoGalleryConnection:ConnectionString"])); // Repositories services.AddScoped <IPhotoRepository, PhotoRepository>(); services.AddScoped <IAlbumRepository, AlbumRepository>(); services.AddScoped <IUserRepository, UserRepository>(); services.AddScoped <IUserRoleRepository, UserRoleRepository>(); services.AddScoped <IRoleRepository, RoleRepository>(); services.AddScoped <ILoggingRepository, LoggingRepository>(); // Services services.AddScoped <IMembershipService, MembershipService>(); services.AddScoped <IEncryptionService, EncryptionService>(); services.AddAuthentication(); // Polices services.AddAuthorization(options => { // inline policies options.AddPolicy("AdminOnly", policy => { policy.RequireClaim(ClaimTypes.Role, "Admin"); }); }); // Add MVC services to the services container. services.AddMvc(); }