refactoring

This commit is contained in:
Vitaliy 2024-06-19 13:20:34 +03:00
parent 183728647e
commit 1dcb66b08d
11 changed files with 22 additions and 22 deletions

View File

@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace HackathonPreparing.ApiService.Auth.EfCore; namespace HackathonPreparing.ApiService.AuthFeature.EfCore;
public class IdentityRoleEntityTypeConfiguration : IEntityTypeConfiguration<IdentityRole<int>> public class IdentityRoleEntityTypeConfiguration : IEntityTypeConfiguration<IdentityRole<int>>
{ {

View File

@ -2,9 +2,9 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace HackathonPreparing.ApiService.Auth.EfCore; namespace HackathonPreparing.ApiService.AuthFeature.EfCore;
public class UserContext : IdentityDbContext<Auth.User, IdentityRole<int>, int> public class UserContext : IdentityDbContext<AuthFeature.User, IdentityRole<int>, int>
{ {
public UserContext (DbContextOptions<UserContext> options) : base(options) {} public UserContext (DbContextOptions<UserContext> options) : base(options) {}

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
namespace HackathonPreparing.ApiService.Auth; namespace HackathonPreparing.ApiService.AuthFeature;
public class User : IdentityUser<int> public class User : IdentityUser<int>
{ {

View File

@ -3,7 +3,7 @@ using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerGen;
namespace HackathonPreparing.ApiService.Auth; namespace HackathonPreparing.ApiService.AuthFeature;
public class UserOpenApiSchemeFilter : ISchemaFilter public class UserOpenApiSchemeFilter : ISchemaFilter
{ {

View File

@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerGen;
namespace HackathonPreparing.ApiService.GlobalHelpers; namespace HackathonPreparing.ApiService.DevFeature;
public static class DbHelpersEndpointsExtensions public static class DbHelpersEndpointsExtensions
{ {
@ -53,8 +53,8 @@ public static class DbHelpersEndpointsExtensions
return Results.Ok(); return Results.Ok();
}); });
group.MapPost("/add-moderator", async ([FromServices]UserManager<Auth.User> userManager) => { group.MapPost("/add-moderator", async ([FromServices]UserManager<AuthFeature.User> userManager) => {
var user = new Auth.User{ var user = new AuthFeature.User{
Email = "m@gmail.com", Email = "m@gmail.com",
UserName = "m@gmail.com" UserName = "m@gmail.com"
}; };

View File

@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace HackathonPreparing.ApiService.GlobalHelpers; namespace HackathonPreparing.ApiService.DevFeature;
public static class ServicesExtensions public static class ServicesExtensions
{ {

View File

@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace HackathonPreparing.ApiService.WeatherForecast.EfCore; namespace HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
public sealed class WeatherForecastContext : DbContext public sealed class WeatherForecastContext : DbContext
{ {
@ -10,7 +10,7 @@ public sealed class WeatherForecastContext : DbContext
} }
public DbSet<WeatherForecast> Forecasts => Set<ApiService.WeatherForecast.WeatherForecast>(); public DbSet<WeatherForecast> Forecasts => Set<ApiService.WeatherForecastFeature.WeatherForecast>();
protected override void OnModelCreating(ModelBuilder builder) protected override void OnModelCreating(ModelBuilder builder)
{ {

View File

@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace HackathonPreparing.ApiService.WeatherForecast.EfCore; namespace HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
public class WeatherForecastEntityTypeConfiguration : IEntityTypeConfiguration<WeatherForecast> public class WeatherForecastEntityTypeConfiguration : IEntityTypeConfiguration<WeatherForecast>
{ {

View File

@ -1,7 +1,7 @@
using HackathonPreparing.ApiService.WeatherForecast.EfCore; using HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace HackathonPreparing.ApiService.WeatherForecast; namespace HackathonPreparing.ApiService.WeatherForecastFeature;
public static class WeatherForecastEndpointsExtensions public static class WeatherForecastEndpointsExtensions
{ {
@ -22,14 +22,14 @@ public static class WeatherForecastEndpointsExtensions
return Results.NoContent(); return Results.NoContent();
}).RequireAuthorization("moderator"); }).RequireAuthorization("moderator");
group.MapPost("/", async (WeatherForecastContext db, ApiService.WeatherForecast.WeatherForecast forecast) => group.MapPost("/", async (WeatherForecastContext db, ApiService.WeatherForecastFeature.WeatherForecast forecast) =>
{ {
db.Forecasts.Add(forecast); db.Forecasts.Add(forecast);
await db.SaveChangesAsync(); await db.SaveChangesAsync();
return Results.Created($"/weatherforecast/{forecast.Id}", forecast); return Results.Created($"/weatherforecast/{forecast.Id}", forecast);
}); });
group.MapPut("/{id}", async (WeatherForecastContext db, int id, ApiService.WeatherForecast.WeatherForecast forecast) => group.MapPut("/{id}", async (WeatherForecastContext db, int id, ApiService.WeatherForecastFeature.WeatherForecast forecast) =>
{ {
if (id != forecast.Id) if (id != forecast.Id)
{ {

View File

@ -1,4 +1,4 @@
namespace HackathonPreparing.ApiService.WeatherForecast; namespace HackathonPreparing.ApiService.WeatherForecastFeature;
public class WeatherForecast public class WeatherForecast
{ {

View File

@ -1,8 +1,8 @@
using HackathonPreparing.ApiService.Auth; using HackathonPreparing.ApiService.AuthFeature;
using HackathonPreparing.ApiService.Auth.EfCore; using HackathonPreparing.ApiService.AuthFeature.EfCore;
using HackathonPreparing.ApiService.GlobalHelpers; using HackathonPreparing.ApiService.DevFeature;
using HackathonPreparing.ApiService.WeatherForecast; using HackathonPreparing.ApiService.WeatherForecastFeature;
using HackathonPreparing.ApiService.WeatherForecast.EfCore; using HackathonPreparing.ApiService.WeatherForecastFeature.EfCore;
using HackathonPreparing.ServiceDefaults; using HackathonPreparing.ServiceDefaults;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;