protected RepositoryBaseTest()
        {
            Connection = new SqliteConnection("DataSource=:memory:");
            Connection.Open();
            var options = new DbContextOptionsBuilder <CoastlineContext>()
                          .UseSqlite(Connection)
                          .Options;

            Context = new CoastlineContext(options);
            Context.Database.EnsureCreatedAsync();
        }
Example #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CoastlineContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler(appBuilder =>
                {
                    appBuilder.Run(async httpContext =>
                    {
                        httpContext.Response.StatusCode = 500;
                        await httpContext.Response.WriteAsync("An unexpected fault has happend. Try again later");
                    });
                });
            }

            if (Configuration["DatabaseMigrations"] == "automatic")
            {
                context.Database.Migrate();
            }

            app.UseRouting();

            app.UseCors(builder =>
            {
                builder.WithOrigins(Configuration["AllowedOrigin"])
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials();
            });

            app.UseAuthentication();
            app.UseAuthorization();

            // Register the Swagger generator and the Swagger UI middlewares
            app.UseOpenApi();
            app.UseSwaggerUi3(options => { options.Path = ""; });

            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }
Example #3
0
 public StudyGroupRepository(CoastlineContext context) : base(context)
 {
 }
 protected RepositoryBase(CoastlineContext context)
 {
     Context = context ?? throw new ArgumentNullException(nameof(context));
 }
Example #5
0
 public ModuleRepository(CoastlineContext context) : base(context)
 {
 }
Example #6
0
 public UserRepository(CoastlineContext context) : base(context)
 {
 }