Files
moadiran/Back/Program.cs

49 lines
1.4 KiB
C#
Raw Normal View History

2024-03-30 15:10:36 +03:30
using Back.Data.Contracts;
using Back.Data.Infrastructure.Repository;
using Back.Services;
using Microsoft.EntityFrameworkCore;
using TaxPayer.Infrastructure.Persistence;
2024-03-29 17:44:38 +03:30
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
2024-03-30 15:10:36 +03:30
builder.Services.AddDbContext<SqlDbContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("Base"));
});
builder.Services.AddScoped(typeof(IAsyncRepository<>), typeof(RepositoryBase<>));
builder.Services.AddScoped<Back.Services.ServBase>();
string origins = "OriginTaxPayer";
builder.Services.AddCors(options =>
{
options.AddPolicy(origins,
policy =>
{
2024-03-31 01:33:17 +03:30
policy.WithOrigins("https://localhost:7224")
2024-03-30 15:10:36 +03:30
.AllowAnyHeader()
.AllowAnyMethod();
});
});
2024-03-29 17:44:38 +03:30
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
2024-03-30 15:10:36 +03:30
app.UseCors(origins);
2024-03-29 17:44:38 +03:30
app.UseAuthorization();
app.MapControllers();
app.Run();