Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddDbContext <DataContext>(options =>
                                                options.UseNpgsql(PostgresUrlParser.ParseConnectionString(Configuration["DATABASE_URL"])));
        }
Exemple #2
0
        // 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 https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            connectionString = PostgresUrlParser.ParseConnectionString(Configuration["DATABASE_URL"]);
            psqlConnection   = PostgresUrlParser.PsqlConnection(Configuration["DATABASE_URL"]);
            getDbConnection  = () => new NpgsqlConnection(connectionString);


            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseNpgsql(connectionString));
            services.AddDefaultIdentity <IdentityUser>(
                options =>
            {
                options.SignIn.RequireConfirmedAccount  = false;
                options.Password.RequireDigit           = false;
                options.Password.RequireLowercase       = false;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequiredUniqueChars    = 0;
                options.Password.RequiredLength         = 0;
            })
            .AddEntityFrameworkStores <ApplicationDbContext>();

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddScoped <AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider <IdentityUser> >();
            services.AddTransient <Func <IDbConnection> >(c => getDbConnection);
            services.AddTransient <Func <string> >(c => () => psqlConnection);
            services.AddTransient <StudentListViewModel>();
            services.AddTransient <StudentDetailViewModel>();
            services.AddTransient <INewNoteViewModel, StudentNoteViewModel>();
            services.AddTransient <IStudentRepository, StudentRepository>();
            services.AddTransient <IClassRepository, ClassRepository>();
            services.AddTransient <ICourseRepository, CourseRepository>();
            services.AddTransient <IAssignmentRepository, AssignmentRepository>();
            services.AddSingleton <IRefreshService, RefreshService>();
            services.AddTransient <ClassListViewModel>();
            services.AddTransient <ClassDetailViewModel>();
            services.AddTransient <SeatingChartViewModel>();
            services.AddTransient <ClassDetailCourseListViewModel>();
            services.AddTransient <CourseDetailViewModel>();
            services.AddTransient <AdminViewModel>();
            services.AddTransient <CourseListViewModel>();
        }