Refactored DTOs to use AutoMapper instead of manual mapping and made some additional improvements and fixes.
Added : GetAllSurveys&DeleteUser.
This commit is contained in:
2025-02-07 06:40:57 -08:00
parent 272ef7194e
commit 3aabe1a367
214 changed files with 10555 additions and 262 deletions

View File

@@ -3,13 +3,14 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using survey_beta.DataBaseContext;
using survey_beta.Mappers.Profiles;
using survey_beta.Models;
using System.Text;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
@@ -65,7 +66,14 @@ builder.Services.AddScoped<UsersServices>();
builder.Services.AddScoped<SurveyService>();
builder.Services.AddScoped<ResponsesService>();
builder.Services.AddScoped<AnalyticsServices>();
builder.Services.AddAutoMapper(typeof(MappingProfile));
builder.Services.AddAutoMapper(typeof(UserProfile));
builder.Services.AddAutoMapper(typeof(ResponseProfile));
builder.Services.AddAutoMapper(typeof(AnalyticsProfile));
builder.Services.AddAutoMapper(typeof(AnswerProfile));
builder.Services.AddAutoMapper(typeof(ChoiceProfile));
builder.Services.AddAutoMapper(typeof(QuestionProfile));
builder.Services.AddAutoMapper(typeof(SurveyProfile));
var app = builder.Build();
// HTTP request pipeline
@@ -74,7 +82,7 @@ if (app.Environment.IsDevelopment())
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();