88 lines
2.8 KiB
C#
88 lines
2.8 KiB
C#
using Back;
|
|
using Back.Data.Contracts;
|
|
using Back.Data.Infrastructure.Repository;
|
|
using Back.Features;
|
|
using Back.Services;
|
|
using Back.Validations;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using System.Text;
|
|
using TaxPayer.Infrastructure.Persistence;
|
|
|
|
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();
|
|
builder.Services.AddDbContext<SqlDbContext>(options =>
|
|
{
|
|
options.UseSqlServer(builder.Configuration.GetConnectionString("Base"));
|
|
});
|
|
builder.Services.AddScoped(typeof(IAsyncRepository<>), typeof(RepositoryBase<>));
|
|
builder.Services.AddScoped<Back.Services.ServBase>();
|
|
builder.Services.AddScoped<MobileValidation> ();
|
|
builder.Services.AddScoped<Service.Main>();
|
|
builder.Services.AddScoped<servTicket > ();
|
|
builder.Services.AddScoped < ServValidatinMsg>();
|
|
builder.Services.AddScoped<GetVerificationValidation> ();
|
|
builder.Services.AddScoped<GetVerificationValidation>();
|
|
builder.Services.AddScoped<CheckPermission>();
|
|
builder.Services.AddScoped<servCompany>();
|
|
builder.Services.AddScoped<servNotification>();
|
|
builder.Services.AddScoped<servPermission>();
|
|
builder.Services.AddScoped<servSendMsg>();
|
|
builder.Services.AddScoped<servUser>();
|
|
builder.Services.AddScoped<CompanyRegistrationValidation>();
|
|
builder.Services.AddScoped(c => new mpNuget.RestClient("09119660045", "C54S2"));
|
|
|
|
string origins = "OriginTaxPayer";
|
|
builder.Services.AddCors(options =>
|
|
{
|
|
options.AddPolicy(origins,
|
|
policy =>
|
|
{
|
|
policy.WithOrigins("https://localhost:7224", "http://localhost:5107")
|
|
.AllowAnyHeader()
|
|
.AllowAnyMethod();
|
|
});
|
|
});
|
|
|
|
#region JWT
|
|
builder.Services.AddAuthentication("Bearer")
|
|
.AddJwtBearer(options =>
|
|
{
|
|
options.TokenValidationParameters = new()
|
|
{
|
|
ValidateIssuer = true,
|
|
ValidateAudience = true,
|
|
ValidateIssuerSigningKey = true,
|
|
ValidIssuer = Fixedvalues.Issuer,
|
|
ValidAudience = Fixedvalues.Audience,
|
|
IssuerSigningKey = new SymmetricSecurityKey(
|
|
Encoding.ASCII.GetBytes(Fixedvalues.SecretForKey))
|
|
};
|
|
}
|
|
);
|
|
#endregion
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseCors(origins);
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
app.UseCheckOnlineUser();
|
|
app.MapControllers();
|
|
|
|
app.Run();
|