Files
moadiran/Back/Program.cs

92 lines
3.0 KiB
C#
Raw Normal View History

2024-04-18 00:33:46 +03:30
using Back;
2024-03-30 15:10:36 +03:30
using Back.Data.Contracts;
using Back.Data.Infrastructure.Repository;
2024-04-29 07:58:41 +03:30
using Back.Features;
2024-03-30 15:10:36 +03:30
using Back.Services;
2024-04-05 01:05:32 +03:30
using Back.Validations;
2024-03-30 15:10:36 +03:30
using Microsoft.EntityFrameworkCore;
2024-04-18 00:33:46 +03:30
using Microsoft.IdentityModel.Tokens;
using System.Text;
2024-03-30 15:10:36 +03:30
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<>));
2024-04-29 18:15:46 +03:30
builder.Services.AddScoped(typeof(RepositoryBase<>), typeof(RepositoryBase<>));
2024-03-30 15:10:36 +03:30
builder.Services.AddScoped<Back.Services.ServBase>();
2024-04-05 01:05:32 +03:30
builder.Services.AddScoped<MobileValidation> ();
builder.Services.AddScoped<Service.Main>();
2024-04-14 16:09:36 +03:30
builder.Services.AddScoped<servTicket > ();
builder.Services.AddScoped < ServValidatinMsg>();
2024-04-15 17:16:17 +03:30
builder.Services.AddScoped<GetVerificationValidation> ();
2024-04-16 12:23:29 +03:30
builder.Services.AddScoped<GetVerificationValidation>();
2024-04-17 15:49:34 +03:30
builder.Services.AddScoped<CheckPermission>();
builder.Services.AddScoped<servCompany>();
builder.Services.AddScoped<servNotification>();
builder.Services.AddScoped<servPermission>();
builder.Services.AddScoped<servSendMsg>();
builder.Services.AddScoped<servUser>();
2024-04-30 16:40:05 +03:30
builder.Services.AddScoped<servTaxPayer>();
2024-05-05 18:15:37 +03:30
builder.Services.AddScoped<servCustomer>();
2024-04-17 15:49:34 +03:30
builder.Services.AddScoped<CompanyRegistrationValidation>();
2024-05-07 17:49:02 +03:30
builder.Services.AddScoped<AddCustomerValidation>();
2024-04-17 15:49:34 +03:30
builder.Services.AddScoped(c => new mpNuget.RestClient("09119660045", "C54S2"));
2024-04-16 12:23:29 +03:30
2024-03-30 15:10:36 +03:30
string origins = "OriginTaxPayer";
builder.Services.AddCors(options =>
{
options.AddPolicy(origins,
policy =>
{
2024-04-02 17:14:18 +03:30
policy.WithOrigins("https://localhost:7224", "http://localhost:5107")
2024-03-30 15:10:36 +03:30
.AllowAnyHeader()
.AllowAnyMethod();
});
});
2024-03-29 17:44:38 +03:30
2024-04-18 00:33:46 +03:30
#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
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-04-18 00:33:46 +03:30
app.UseAuthentication();
2024-03-29 17:44:38 +03:30
app.UseAuthorization();
2024-04-29 07:58:41 +03:30
app.UseCheckOnlineUser();
2024-03-29 17:44:38 +03:30
app.MapControllers();
app.Run();