Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions API/API.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.11">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.6" />
</ItemGroup>

<ItemGroup>
Expand All @@ -22,4 +22,11 @@
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup>

</Project>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion API/Controllers/AuthorController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Application.Commands.AuthorCommands.AddAuthor;
using Application.Commands.AuthorCommands.Add;
using Application.Commands.AuthorCommands.DeleteAuthor;
using Application.Commands.AuthorCommands.UpdateAuthor;
using Application.Dtos;
Expand Down
2 changes: 1 addition & 1 deletion API/Controllers/GenreController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Application.Commands.AuthorCommands.AddAuthor;
using Application.Commands.AuthorCommands.Add;
using Application.Commands.GenreCommands.AddGenre;
using Application.Commands.GenreCommands.DeleteGenre;
using Application.Commands.GenreCommands.UpdateGenre;
Expand Down
6 changes: 3 additions & 3 deletions Application/Application.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -13,8 +13,8 @@
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
<PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.11" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.11" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.35.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.35.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Domain.Entities.Core;
using MediatR;

namespace Application.Commands.AuthorCommands.AddAuthor
namespace Application.Commands.AuthorCommands.Add
{
public class AddAuthorCommand(AddAuthorDto author) : IRequest<OperationResult<Author>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Domain.Entities.Core;
using MediatR;

namespace Application.Commands.AuthorCommands.AddAuthor
namespace Application.Commands.AuthorCommands.Add
{
public class AddAuthorCommandHandler(IGenericRepository<Author, Guid> repository, IMapper mapper) : IRequestHandler<AddAuthorCommand, OperationResult<Author>>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentValidation;

namespace Application.Commands.AuthorCommands.AddAuthor
namespace Application.Commands.AuthorCommands.Add
{
public class AddAuthorCommandValidator : AbstractValidator<AddAuthorCommand>
{
Expand Down
2 changes: 1 addition & 1 deletion Application/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Application.Mappings;
using MediatR;
using FluentValidation.AspNetCore;
using Application.Commands.AuthorCommands.AddAuthor;
using Application.Commands.AuthorCommands.Add;
using FluentValidation;

namespace Application
Expand Down
4 changes: 2 additions & 2 deletions Domain/Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.11" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace Infrastructure.Database
{
public class RealDatabase : IdentityDbContext<User, IdentityRole, string>
public class DatabaseContext : IdentityDbContext<User, IdentityRole, string>
{
public RealDatabase(DbContextOptions<RealDatabase> options) : base(options) { }
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }

public DbSet<Author> Authors { get; set; }
public DbSet<Book> Books { get; set; }
Expand Down Expand Up @@ -111,6 +111,5 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Property(r => r.Id)
.ValueGeneratedOnAdd();
}

}
}
37 changes: 37 additions & 0 deletions Infrastructure/Database/DatabasecontextFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;

namespace Infrastructure.Database
{
// Provides a design-time factory so EF tools can create RealDatabase.
public class RealDatabaseFactory : IDesignTimeDbContextFactory<DatabaseContext>
{
public DatabaseContext CreateDbContext(string[] args)
{
// Use the current directory (startup project when running dotnet ef) and read configuration.
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddEnvironmentVariables();

var configuration = builder.Build();

var connectionString = configuration.GetConnectionString("DefaultConnection")
?? Environment.GetEnvironmentVariable("DefaultConnection");

if (string.IsNullOrWhiteSpace(connectionString))
{
throw new InvalidOperationException(
"Connection string 'DefaultConnection' was not found. " +
"Provide it in appsettings.json, appsettings.Development.json, or as the environment variable 'DefaultConnection'.");
}

var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
optionsBuilder.UseSqlServer(connectionString);

return new DatabaseContext(optionsBuilder.Options);
}
}
}
4 changes: 2 additions & 2 deletions Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class DependencyInjection
public static IServiceCollection AddInfrastructure(this IServiceCollection services, string connectionString)

{
services.AddDbContext<RealDatabase>(options =>
services.AddDbContext<DatabaseContext>(options =>
{
options.UseSqlServer(connectionString);
});
Expand All @@ -23,7 +23,7 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi

services.AddIdentityCore<User>()
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<RealDatabase>();
.AddEntityFrameworkStores<DatabaseContext>();

return services;
}
Expand Down
14 changes: 9 additions & 5 deletions Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -16,10 +16,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.11" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.11" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading