public void Initialize(Uri functionsEndpoint, string sqlConnectionString) { if (IsInitialized) return; if (functionsEndpoint == null) throw new InvalidDataException("DocumentDB settings are invalid"); if (String.IsNullOrEmpty(sqlConnectionString)) throw new InvalidDataException("Sql settings are invalid"); try { //EF initialization EFRepositoryFactory factory = new EFRepositoryFactory(); ParkingsStore = factory.CreateRepository<Parking>(sqlConnectionString); SpacesStore = factory.CreateRepository<Space>(sqlConnectionString); //NoSql initialization //this class expect a configuration AccessLedger = new LedgerServerLess(functionsEndpoint); AccessLedger.Initialize(); IsInitialized = AccessLedger.IsInizialized; } catch (Exception) { IsInitialized = false; } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); services.AddScoped <IRepository>(serviceProvider => EFRepositoryFactory.GetInstance(Configuration["DbConnStr"])); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.AddSession(); // Add framework services. services.AddMvc(); services.AddScoped <IRepository>(serviceProvider => EFRepositoryFactory.GetInstance(Configuration["DbConnStr"])); services.AddAuthorization(options => { options.AddPolicy("AdminOnly", policy => policy.RequireClaim("IsAdmin")); }); }