School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,48 @@
using Lab9.Context;
using Lab9.Repositories;
using Microsoft.EntityFrameworkCore;
namespace Lab9
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddSession(options =>
{
options.Cookie.Name = "SessionId";
options.Cookie.IsEssential = true;
});
builder.Services.AddDbContext<NewsContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("NewsDB")));
builder.Services.AddScoped<IRepository,Repository>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/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.UseAuthorization();
app.UseSession();
app.MapControllers();
app.Run();
}
}
}