2021-07-21 00:08:57 +00:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Props.Data;
|
2021-07-21 06:58:49 +00:00
|
|
|
using Props.Models.User;
|
2021-07-22 21:12:27 +00:00
|
|
|
using Props.Services.Modules;
|
2022-04-25 03:20:35 +00:00
|
|
|
using System;
|
2021-07-21 00:08:57 +00:00
|
|
|
|
|
|
|
namespace Props
|
|
|
|
{
|
|
|
|
public class Startup
|
|
|
|
{
|
|
|
|
public Startup(IConfiguration configuration, IWebHostEnvironment webHostEnvironment)
|
|
|
|
{
|
|
|
|
Configuration = configuration;
|
|
|
|
environment = webHostEnvironment;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
private readonly IWebHostEnvironment environment;
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
{
|
|
|
|
if (environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
services.AddDbContext<ApplicationDbContext>(options =>
|
2021-07-21 06:58:49 +00:00
|
|
|
{
|
|
|
|
options.UseLazyLoadingProxies();
|
|
|
|
options.UseSqlite(Configuration.GetConnectionString("DefaultConnection"));
|
|
|
|
});
|
2021-07-21 00:08:57 +00:00
|
|
|
services.AddDatabaseDeveloperPageExceptionFilter();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
services.AddDbContext<ApplicationDbContext>(options =>
|
2021-07-21 06:58:49 +00:00
|
|
|
{
|
|
|
|
options.UseLazyLoadingProxies();
|
|
|
|
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
|
|
|
|
});
|
2021-07-21 00:08:57 +00:00
|
|
|
}
|
|
|
|
services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
|
|
|
.AddEntityFrameworkStores<ApplicationDbContext>();
|
|
|
|
services.AddRazorPages();
|
|
|
|
|
2021-08-05 06:22:19 +00:00
|
|
|
services.AddSingleton<IShopManager, ModularShopManager>();
|
|
|
|
services.AddScoped<IMetricsManager, LiveMetricsManager>();
|
|
|
|
services.AddScoped<ISearchManager, LiveSearchManager>();
|
2021-07-21 00:08:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
|
public void Configure(IApplicationBuilder app)
|
|
|
|
{
|
|
|
|
if (environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
}
|
|
|
|
app.UseMigrationsEndPoint();
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
|
|
app.UseAuthentication();
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
{
|
2021-07-22 21:12:27 +00:00
|
|
|
endpoints.MapControllers();
|
2021-07-21 00:08:57 +00:00
|
|
|
endpoints.MapRazorPages();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|