Example #1
0
        public void Configure(IBlazorApplicationBuilder app, WebsitesContext context)
        {
            //Populate initial data
            context.SeedData().GetAwaiter().GetResult();

            app.AddComponent <App>("app");
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, WebsitesContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            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.UseSpaStaticFiles();
            var options = new HealthCheckOptions();

            options.ResponseWriter = async(c, r) =>
            {
                c.Response.ContentType = "application/json";

                var result = JsonConvert.SerializeObject(new
                {
                    status = r.Status.ToString(),
                    errors = r.Entries.Select(e => new { key = e.Key, value = e.Value.Status.ToString() })
                });
                await c.Response.WriteAsync(result);
            };
            app.UseHealthChecks("/working", options);
            app.UseHealthChecksUI();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });

            //For MSSql
            //context.Database.Migrate();

            //Populate initial data
            context.SeedData().GetAwaiter().GetResult();
        }
Example #3
0
        public void Setup()
        {
            var services = new ServiceCollection();

            services.AddDbContext <WebsitesContext>(options => options.UseInMemoryDatabase(), ServiceLifetime.Singleton);
            services.AddSingleton <WebsiteDataService>();
            var serviceProvider = services.BuildServiceProvider();

            testContext = serviceProvider.GetService <WebsitesContext>();
            testContext.SeedData().GetAwaiter().GetResult();
            websiteService = new WebsiteDataService(testContext);
        }
Example #4
0
 public AccountController(
     UserManager <User> userManager,
     SignInManager <User> signInManager,
     ILogger <AccountController> logger,
     RoleManager <IdentityRole> roleManager,
     WebsitesContext context)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _logger        = logger;
     _roleManager   = roleManager;
     _context       = context;
 }
        public void SetUp()
        {
            var services = new ServiceCollection();

            services.AddDbContext <WebsitesContext>(options => options.UseInMemoryDatabase(), ServiceLifetime.Singleton);
            services.AddSingleton <WebsitesController>();
            services.AddSingleton <SampleDataController>();
            var serviceProvider = services.BuildServiceProvider();

            _testContext = serviceProvider.GetService <WebsitesContext>();
            _testContext.SeedData().GetAwaiter().GetResult();
            _websitesController   = serviceProvider.GetService <WebsitesController>();
            _sampleDataController = serviceProvider.GetService <SampleDataController>();
        }
Example #6
0
 public ApplicationDbInitializer(WebsitesContext context, UserManager <User> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }
 public WebsiteDataService(WebsitesContext context)
 {
     _context = context;
 }
Example #8
0
 public OrdersController(WebsitesContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #9
0
 public WebsitesController(WebsitesContext context, UserManager <User> userManager, IMapper mapper)
 {
     _context     = context;
     _userManager = userManager;
     _mapper      = mapper;
 }
 public WebsitesController(WebsitesContext context)
 {
     _context = context;
 }