Add Identity configuration, DTOs and Mappers

-Configured Identity using a custom User model to manage authentication and authorization, to be used in the project.
- Added multiple DTOs (Data Transfer Objects).
- Added multiple Mappers ( manual mapping).
- Updated AppDbContext and User model to fully integrate with Identity framework for user management.
-Added relationships between models.
Note : no migration yet
This commit is contained in:
2025-01-20 07:17:35 -08:00
parent 2fa9c6fa80
commit 78900ab7ad
22 changed files with 350 additions and 6 deletions

View File

@@ -1,21 +1,30 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using survey_beta.DataBaseContext;
using survey_beta.Models;
using survey_beta.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
var app = builder.Build();
// Configure the HTTP request pipeline.
builder.Services.AddIdentity<User, IdentityRole>()
.AddEntityFrameworkStores<AppDbContext>()
.AddDefaultTokenProviders();
builder.Services.AddScoped<UserService>();
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();