示例#1
0
        private void CreateDefaultConfig(CategoriseContext context)
        {
            ConfigSettingService configSettingService = new ConfigSettingService(context);

            // Create required configs (safely).
            configSettingService.CreateConfigSetting("AllowRegistrations", "false", true);
        }
示例#2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, CategoriseContext context, IWebHostEnvironment env)
        {
            CreateDefaultConfig(context);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseMigrationsEndPoint();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

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

            var blockRegistration = context.ConfigSettings.Where(c => c.Name == "AllowRegistrations").FirstOrDefault().Value == "false";

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");

                if (blockRegistration)
                {
                    endpoints.MapGet("/Identity/Account/Register", context => Task.Factory.StartNew(() => context.Response.Redirect("/Identity/Account/Login", true)));
                    endpoints.MapPost("/Identity/Account/Register", context => Task.Factory.StartNew(() => context.Response.Redirect("/Identity/Account/Login", true)));
                }
            });
        }
示例#3
0
 /// <summary>
 /// Constructor for the ConfigSettingService.
 /// </summary>
 public ConfigSettingService(CategoriseContext context)
 {
     _context = context;
 }
 /// <summary>
 /// Constructor for the CategoryService.
 /// </summary>
 public CategoryService(CategoriseContext context)
 {
     _context = context;
 }
示例#5
0
 /// <summary>
 /// Constructor for the AccountService.
 /// </summary>
 public AccountService(CategoriseContext context)
 {
     _context = context;
 }
示例#6
0
 /// <summary>
 /// Constructor for the VendorService.
 /// </summary>
 public VendorService(CategoriseContext context)
 {
     _context = context;
 }
 /// <summary>
 /// Constructor for TransactionService.
 /// </summary>
 public TransactionService(CategoriseContext context)
 {
     _context = context;
 }