Refactoring V3
This commit is contained in:
parent
0f710abf3c
commit
34eaf01df0
@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace HackathonPreparing.ApiService.AuthFeature.EfCore;
|
||||
namespace HackathonPreparing.ApiService.Features.AuthFeature.EfCore;
|
||||
|
||||
public class IdentityRoleEntityTypeConfiguration : IEntityTypeConfiguration<IdentityRole<int>>
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HackathonPreparing.ApiService.AuthFeature.EfCore;
|
||||
namespace HackathonPreparing.ApiService.Features.AuthFeature.EfCore;
|
||||
|
||||
public class UserContext : IdentityDbContext<User, IdentityRole<int>, int>
|
||||
{
|
||||
@ -11,8 +11,6 @@ public class UserContext : IdentityDbContext<User, IdentityRole<int>, int>
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace HackathonPreparing.ApiService.AuthFeature;
|
||||
namespace HackathonPreparing.ApiService.Features.AuthFeature;
|
||||
|
||||
public class User : IdentityUser<int>
|
||||
{
|
||||
|
@ -3,7 +3,7 @@ using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace HackathonPreparing.ApiService.AuthFeature;
|
||||
namespace HackathonPreparing.ApiService.Features.AuthFeature;
|
||||
|
||||
public class UserOpenApiSchemeFilter : ISchemaFilter
|
||||
{
|
||||
|
@ -1,11 +1,10 @@
|
||||
using HackathonPreparing.ApiService.Features.AuthFeature;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using static HackathonPreparing.ApiService.Features.DevFeature.ReflectionHelpers;
|
||||
|
||||
|
||||
namespace HackathonPreparing.ApiService.DevFeature;
|
||||
namespace HackathonPreparing.ApiService.Features.DevFeature;
|
||||
|
||||
public static class DbHelpersEndpointsExtensions
|
||||
{
|
||||
@ -70,8 +69,8 @@ public static class DbHelpersEndpointsExtensions
|
||||
});
|
||||
|
||||
|
||||
group.MapPost("/add-moderator", async ([FromServices]UserManager<AuthFeature.User> userManager) => {
|
||||
var user = new AuthFeature.User{
|
||||
group.MapPost("/add-moderator", async ([FromServices]UserManager<User> userManager) => {
|
||||
var user = new User{
|
||||
Email = "m@gmail.com",
|
||||
UserName = "m@gmail.com"
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
namespace HackathonPreparing.ApiService.DevFeature;
|
||||
namespace HackathonPreparing.ApiService.Features.DevFeature;
|
||||
|
||||
public static class ServicesExtensions
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
|
||||
namespace HackathonPreparing.ApiService.Features.WeatherForecastFeature.EfCore;
|
||||
|
||||
public sealed class WeatherForecastContext : DbContext
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
|
||||
namespace HackathonPreparing.ApiService.Features.WeatherForecastFeature.EfCore;
|
||||
|
||||
public class WeatherForecastEntityTypeConfiguration : IEntityTypeConfiguration<WeatherForecast>
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
using HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using HackathonPreparing.ApiService.Features.WeatherForecastFeature.EfCore;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace HackathonPreparing.ApiService.WeatherForecastFeature;
|
||||
namespace HackathonPreparing.ApiService.Features.WeatherForecastFeature;
|
||||
|
||||
public static class WeatherForecastEndpointsExtensions
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace HackathonPreparing.ApiService.WeatherForecastFeature;
|
||||
namespace HackathonPreparing.ApiService.Features.WeatherForecastFeature;
|
||||
|
||||
public class WeatherForecast
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HackathonPreparing.ApiService.AuthFeature.EfCore;
|
||||
using HackathonPreparing.ApiService.Features.AuthFeature.EfCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HackathonPreparing.ApiService.AuthFeature.EfCore;
|
||||
using HackathonPreparing.ApiService.Features.AuthFeature.EfCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
|
||||
using HackathonPreparing.ApiService.Features.WeatherForecastFeature.EfCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
@ -1,6 +1,6 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
|
||||
using HackathonPreparing.ApiService.Features.WeatherForecastFeature.EfCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
@ -1,8 +1,8 @@
|
||||
using HackathonPreparing.ApiService.AuthFeature;
|
||||
using HackathonPreparing.ApiService.AuthFeature.EfCore;
|
||||
using HackathonPreparing.ApiService.DevFeature;
|
||||
using HackathonPreparing.ApiService.WeatherForecastFeature;
|
||||
using HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
|
||||
using HackathonPreparing.ApiService.Features.AuthFeature;
|
||||
using HackathonPreparing.ApiService.Features.AuthFeature.EfCore;
|
||||
using HackathonPreparing.ApiService.Features.DevFeature;
|
||||
using HackathonPreparing.ApiService.Features.WeatherForecastFeature;
|
||||
using HackathonPreparing.ApiService.Features.WeatherForecastFeature.EfCore;
|
||||
using HackathonPreparing.ServiceDefaults;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
@ -38,11 +38,7 @@ builder.Services.AddSwaggerGen(c =>
|
||||
//we dont need it now
|
||||
//builder.AddServiceDefaults();
|
||||
|
||||
|
||||
|
||||
builder.Services.AddAuthorization();
|
||||
|
||||
|
||||
builder.Services.AddAuthentication().AddBearerToken();
|
||||
|
||||
builder.Services
|
||||
@ -57,8 +53,6 @@ builder.AddDbContextWithDefaultConfiguration<UserContext>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
|
||||
app.UsePathBase("/api");
|
||||
app.UseRouting();
|
||||
|
||||
@ -73,20 +67,15 @@ if (app.Environment.IsDevelopment())
|
||||
app.AddDbHelpersEndpoints();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Configure the HTTP request pipeline.
|
||||
app.UseExceptionHandler();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
app.AddWeatherForecastEndpoints();
|
||||
app.MapDefaultEndpoints();
|
||||
|
||||
|
||||
|
||||
app.MapGroup("user")
|
||||
.MapIdentityApi<User>()
|
||||
.WithTags("user");
|
||||
|
Loading…
x
Reference in New Issue
Block a user