From 7e895d5e5f66b94ce2f06b9a6a0e3edb3809cff8 Mon Sep 17 00:00:00 2001 From: Tajerbashi Date: Sat, 3 Aug 2024 10:35:33 +0330 Subject: [PATCH] Feature : Change Base Sources --- .../Aggregates/People/Entities/Person.cs | 4 +- .../BaseCommandDbContext.cs | 3 +- ...0240624093534_Initial_Database.Designer.cs | 68 ---- .../20240624093534_Initial_Database.cs | 46 --- .../20240624145120_Change.Designer.cs | 72 ---- .../Migrations/20240624145120_Change.cs | 31 -- .../20240624150118_Change_V1.Designer.cs | 76 ---- .../Migrations/20240624150118_Change_V1.cs | 31 -- .../20240624164734_Add_User.Designer.cs | 126 ------ .../Migrations/20240624164734_Add_User.cs | 49 --- ...0240803070423_Initial_Database.Designer.cs | 375 ++++++++++++++++++ .../20240803070423_Initial_Database.cs | 283 +++++++++++++ ...bContextApplicationCommandModelSnapshot.cs | 253 +++++++++++- .../BaseQueryDbContext.cs | 3 +- ...0240624144319_Initial_Database.Designer.cs | 54 --- .../20240624144319_Initial_Database.cs | 23 -- ...bContextApplicationQueriesModelSnapshot.cs | 51 --- .../Controllers/BaseController.cs | 2 +- .../Controllers/Account/AccountController.cs | 11 + .../Controllers/CatalogItemController.cs | 9 +- .../Controllers/HomeController.cs | 28 +- .../Controllers/PersonController.cs | 12 +- .../Controllers/Security/RoleController.cs | 11 + .../{ => Security}/UserController.cs | 10 +- 24 files changed, 956 insertions(+), 675 deletions(-) delete mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624093534_Initial_Database.Designer.cs delete mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624093534_Initial_Database.cs delete mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624145120_Change.Designer.cs delete mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624145120_Change.cs delete mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624150118_Change_V1.Designer.cs delete mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624150118_Change_V1.cs delete mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624164734_Add_User.Designer.cs delete mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624164734_Add_User.cs create mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240803070423_Initial_Database.Designer.cs create mode 100644 Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240803070423_Initial_Database.cs delete mode 100644 Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/20240624144319_Initial_Database.Designer.cs delete mode 100644 Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/20240624144319_Initial_Database.cs delete mode 100644 Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/DbContextApplicationQueriesModelSnapshot.cs rename Src/4.EndPoints/WebApi.EndPoints/{WebApiBase => BaseWebApi}/Controllers/BaseController.cs (98%) create mode 100644 Src/4.EndPoints/WebApi.EndPoints/Controllers/Account/AccountController.cs create mode 100644 Src/4.EndPoints/WebApi.EndPoints/Controllers/Security/RoleController.cs rename Src/4.EndPoints/WebApi.EndPoints/Controllers/{ => Security}/UserController.cs (73%) diff --git a/Src/1.Domain/CleanArchitectureCQRS.Domain.Library/Aggregates/People/Entities/Person.cs b/Src/1.Domain/CleanArchitectureCQRS.Domain.Library/Aggregates/People/Entities/Person.cs index c3b304a..f18c120 100644 --- a/Src/1.Domain/CleanArchitectureCQRS.Domain.Library/Aggregates/People/Entities/Person.cs +++ b/Src/1.Domain/CleanArchitectureCQRS.Domain.Library/Aggregates/People/Entities/Person.cs @@ -6,7 +6,7 @@ namespace CleanArchitectureCQRS.Domain.Library.Aggregates.People.Entities; -[Table("People", Schema = "Test"), Description("Users System")] +[Table("People", Schema = "BUS"), Description("Users System")] public class Person : AggregateRoot { #region Properties @@ -30,6 +30,6 @@ public Person(string firstName, string lastName, string email, string phone) public void ChangeFirstName(string firstName) { FirstName = firstName; - // AddEvent(new PersonNameChanged(Id, firstName)); + // AddEvent(new PersonNameChanged(Id, firstName)); } } \ No newline at end of file diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/BaseCommandInfrastrcture/BaseCommandDbContext.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/BaseCommandInfrastrcture/BaseCommandDbContext.cs index 21ced79..540c3e3 100644 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/BaseCommandInfrastrcture/BaseCommandDbContext.cs +++ b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/BaseCommandInfrastrcture/BaseCommandDbContext.cs @@ -1,6 +1,7 @@ using CleanArchitectureCQRS.CommandsDb.Library.BaseCommandInfrastrcture.Extensions; using CleanArchitectureCQRS.ContextDatabase.Library.ValueConversions; using CleanArchitectureCQRS.Domain.Library.BaseDomain.ValueObjects; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; @@ -12,7 +13,7 @@ namespace CleanArchitectureCQRS.CommandsDb.Library.BaseCommandInfrastrcture; /// /// /// -public abstract class BaseCommandDbContext : DbContext +public abstract class BaseCommandDbContext : IdentityDbContext { protected IDbContextTransaction _transaction; diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624093534_Initial_Database.Designer.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624093534_Initial_Database.Designer.cs deleted file mode 100644 index 48bcfc3..0000000 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624093534_Initial_Database.Designer.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -using System; -using CleanArchitectureCQRS.CommandsDb.Library.Database; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations -{ - [DbContext(typeof(DbContextApplicationCommand))] - [Migration("20240624093534_Initial_Database")] - partial class Initial_Database - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.People.Entities.Person", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("BusinessId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedDateTime") - .HasColumnType("datetime2"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedDateTime") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.ToTable("People", "Test"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624093534_Initial_Database.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624093534_Initial_Database.cs deleted file mode 100644 index 1428619..0000000 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624093534_Initial_Database.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations -{ - /// - public partial class Initial_Database : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "Test"); - - migrationBuilder.CreateTable( - name: "People", - schema: "Test", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - FirstName = table.Column(type: "nvarchar(max)", nullable: false), - LastName = table.Column(type: "nvarchar(max)", nullable: false), - CreatedByUserId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - CreatedDateTime = table.Column(type: "datetime2", nullable: true), - ModifiedByUserId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - ModifiedDateTime = table.Column(type: "datetime2", nullable: true), - BusinessId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_People", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "People", - schema: "Test"); - } - } -} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624145120_Change.Designer.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624145120_Change.Designer.cs deleted file mode 100644 index 1c23d34..0000000 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624145120_Change.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -using System; -using CleanArchitectureCQRS.CommandsDb.Library.Database; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations -{ - [DbContext(typeof(DbContextApplicationCommand))] - [Migration("20240624145120_Change")] - partial class Change - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.People.Entities.Person", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("BusinessId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedDateTime") - .HasColumnType("datetime2"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedDateTime") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.ToTable("People", "Test"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624145120_Change.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624145120_Change.cs deleted file mode 100644 index 99424ef..0000000 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624145120_Change.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations -{ - /// - public partial class Change : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Email", - schema: "Test", - table: "People", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Email", - schema: "Test", - table: "People"); - } - } -} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624150118_Change_V1.Designer.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624150118_Change_V1.Designer.cs deleted file mode 100644 index 4ad7a25..0000000 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624150118_Change_V1.Designer.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -using System; -using CleanArchitectureCQRS.CommandsDb.Library.Database; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations -{ - [DbContext(typeof(DbContextApplicationCommand))] - [Migration("20240624150118_Change_V1")] - partial class Change_V1 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.People.Entities.Person", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("BusinessId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedDateTime") - .HasColumnType("datetime2"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedDateTime") - .HasColumnType("datetime2"); - - b.Property("Phone") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("People", "Test"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624150118_Change_V1.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624150118_Change_V1.cs deleted file mode 100644 index 954fd43..0000000 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624150118_Change_V1.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations -{ - /// - public partial class Change_V1 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Phone", - schema: "Test", - table: "People", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Phone", - schema: "Test", - table: "People"); - } - } -} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624164734_Add_User.Designer.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624164734_Add_User.Designer.cs deleted file mode 100644 index caa9c54..0000000 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624164734_Add_User.Designer.cs +++ /dev/null @@ -1,126 +0,0 @@ -// -using System; -using CleanArchitectureCQRS.CommandsDb.Library.Database; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations -{ - [DbContext(typeof(DbContextApplicationCommand))] - [Migration("20240624164734_Add_User")] - partial class Add_User - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.People.Entities.Person", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("BusinessId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedDateTime") - .HasColumnType("datetime2"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedDateTime") - .HasColumnType("datetime2"); - - b.Property("Phone") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("People", "Test"); - }); - - modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.Users.Entities.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("BusinessId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("CreatedDateTime") - .HasColumnType("datetime2"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ModifiedByUserId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ModifiedDateTime") - .HasColumnType("datetime2"); - - b.Property("Phone") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Users", "Security"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624164734_Add_User.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624164734_Add_User.cs deleted file mode 100644 index 48065c1..0000000 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240624164734_Add_User.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations -{ - /// - public partial class Add_User : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "Security"); - - migrationBuilder.CreateTable( - name: "Users", - schema: "Security", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - FirstName = table.Column(type: "nvarchar(max)", nullable: false), - LastName = table.Column(type: "nvarchar(max)", nullable: false), - UserName = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - Phone = table.Column(type: "nvarchar(max)", nullable: false), - CreatedByUserId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - CreatedDateTime = table.Column(type: "datetime2", nullable: true), - ModifiedByUserId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - ModifiedDateTime = table.Column(type: "datetime2", nullable: true), - BusinessId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Users", - schema: "Security"); - } - } -} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240803070423_Initial_Database.Designer.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240803070423_Initial_Database.Designer.cs new file mode 100644 index 0000000..baee2e1 --- /dev/null +++ b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240803070423_Initial_Database.Designer.cs @@ -0,0 +1,375 @@ +// +using System; +using CleanArchitectureCQRS.CommandsDb.Library.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations +{ + [DbContext(typeof(DbContextApplicationCommand))] + [Migration("20240803070423_Initial_Database")] + partial class Initial_Database + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.People.Entities.Person", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BusinessId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedByUserId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ModifiedByUserId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedDateTime") + .HasColumnType("datetime2"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("People", "BUS"); + }); + + modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.Users.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BusinessId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedByUserId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedDateTime") + .HasColumnType("datetime2"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ModifiedByUserId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ModifiedDateTime") + .HasColumnType("datetime2"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Users", "Security"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240803070423_Initial_Database.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240803070423_Initial_Database.cs new file mode 100644 index 0000000..e1144f8 --- /dev/null +++ b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/20240803070423_Initial_Database.cs @@ -0,0 +1,283 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CleanArchitectureCQRS.CommandsDb.Library.Migrations +{ + /// + public partial class Initial_Database : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "BUS"); + + migrationBuilder.EnsureSchema( + name: "Security"); + + migrationBuilder.CreateTable( + name: "AspNetRoles", + columns: table => new + { + Id = table.Column(type: "nvarchar(450)", nullable: false), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetUsers", + columns: table => new + { + Id = table.Column(type: "nvarchar(450)", nullable: false), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "bit", nullable: false), + PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), + SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true), + PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false), + TwoFactorEnabled = table.Column(type: "bit", nullable: false), + LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), + LockoutEnabled = table.Column(type: "bit", nullable: false), + AccessFailedCount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "People", + schema: "BUS", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FirstName = table.Column(type: "nvarchar(max)", nullable: false), + LastName = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Phone = table.Column(type: "nvarchar(max)", nullable: false), + CreatedByUserId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + CreatedDateTime = table.Column(type: "datetime2", nullable: true), + ModifiedByUserId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + ModifiedDateTime = table.Column(type: "datetime2", nullable: true), + BusinessId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_People", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + schema: "Security", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FirstName = table.Column(type: "nvarchar(max)", nullable: false), + LastName = table.Column(type: "nvarchar(max)", nullable: false), + UserName = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Phone = table.Column(type: "nvarchar(max)", nullable: false), + CreatedByUserId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + CreatedDateTime = table.Column(type: "datetime2", nullable: true), + ModifiedByUserId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + ModifiedDateTime = table.Column(type: "datetime2", nullable: true), + BusinessId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetRoleClaims", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RoleId = table.Column(type: "nvarchar(450)", nullable: false), + ClaimType = table.Column(type: "nvarchar(max)", nullable: true), + ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserClaims", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(450)", nullable: false), + ClaimType = table.Column(type: "nvarchar(max)", nullable: true), + ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetUserClaims_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserLogins", + columns: table => new + { + LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), + ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), + ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), + UserId = table.Column(type: "nvarchar(450)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_AspNetUserLogins_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserRoles", + columns: table => new + { + UserId = table.Column(type: "nvarchar(450)", nullable: false), + RoleId = table.Column(type: "nvarchar(450)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserTokens", + columns: table => new + { + UserId = table.Column(type: "nvarchar(450)", nullable: false), + LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), + Name = table.Column(type: "nvarchar(450)", nullable: false), + Value = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AspNetUserTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AspNetRoleClaims_RoleId", + table: "AspNetRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "AspNetRoles", + column: "NormalizedName", + unique: true, + filter: "[NormalizedName] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserClaims_UserId", + table: "AspNetUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserLogins_UserId", + table: "AspNetUserLogins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserRoles_RoleId", + table: "AspNetUserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + table: "AspNetUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + table: "AspNetUsers", + column: "NormalizedUserName", + unique: true, + filter: "[NormalizedUserName] IS NOT NULL"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AspNetRoleClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserLogins"); + + migrationBuilder.DropTable( + name: "AspNetUserRoles"); + + migrationBuilder.DropTable( + name: "AspNetUserTokens"); + + migrationBuilder.DropTable( + name: "People", + schema: "BUS"); + + migrationBuilder.DropTable( + name: "Users", + schema: "Security"); + + migrationBuilder.DropTable( + name: "AspNetRoles"); + + migrationBuilder.DropTable( + name: "AspNetUsers"); + } + } +} diff --git a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/DbContextApplicationCommandModelSnapshot.cs b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/DbContextApplicationCommandModelSnapshot.cs index b119b23..a2a9d86 100644 --- a/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/DbContextApplicationCommandModelSnapshot.cs +++ b/Src/3.Infrastructure/DataAccessCommands/CleanArchitectureCQRS.CommandsDb.Library/Migrations/DbContextApplicationCommandModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("ProductVersion", "8.0.7") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -65,7 +65,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("People", "Test"); + b.ToTable("People", "BUS"); }); modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.Users.Entities.User", b => @@ -117,6 +117,255 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Users", "Security"); }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); #pragma warning restore 612, 618 } } diff --git a/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/BaseQueriesInfrastrcture/BaseQueryDbContext.cs b/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/BaseQueriesInfrastrcture/BaseQueryDbContext.cs index 4559738..e30a0df 100644 --- a/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/BaseQueriesInfrastrcture/BaseQueryDbContext.cs +++ b/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/BaseQueriesInfrastrcture/BaseQueryDbContext.cs @@ -1,6 +1,7 @@ using CleanArchitectureCQRS.ContextDatabase.Library.ValueConversions; using CleanArchitectureCQRS.Domain.Library.Aggregates.People.ValueObjects; using CleanArchitectureCQRS.Domain.Library.BaseDomain.ValueObjects; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; namespace CleanArchitectureCQRS.QueriesDb.Library.BaseQueriesInfrastrcture; @@ -8,7 +9,7 @@ namespace CleanArchitectureCQRS.QueriesDb.Library.BaseQueriesInfrastrcture; /// /// /// -public abstract class BaseQueryDbContext : DbContext +public abstract class BaseQueryDbContext : IdentityDbContext { public BaseQueryDbContext(DbContextOptions options) : base(options) { } diff --git a/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/20240624144319_Initial_Database.Designer.cs b/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/20240624144319_Initial_Database.Designer.cs deleted file mode 100644 index f081362..0000000 --- a/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/20240624144319_Initial_Database.Designer.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -using System; -using CleanArchitectureCQRS.QueriesDb.Library.Database; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace CleanArchitectureCQRS.QueriesDb.Library.Migrations -{ - [DbContext(typeof(DbContextApplicationQueries))] - [Migration("20240624144319_Initial_Database")] - partial class Initial_Database - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.People.Entities.Person", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("BusinessId") - .HasColumnType("uniqueidentifier"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("People", "Test"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/20240624144319_Initial_Database.cs b/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/20240624144319_Initial_Database.cs deleted file mode 100644 index 1e6d3d5..0000000 --- a/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/20240624144319_Initial_Database.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace CleanArchitectureCQRS.QueriesDb.Library.Migrations -{ - /// - public partial class Initial_Database : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/DbContextApplicationQueriesModelSnapshot.cs b/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/DbContextApplicationQueriesModelSnapshot.cs deleted file mode 100644 index fb651ad..0000000 --- a/Src/3.Infrastructure/DataAccessQueries/CleanArchitectureCQRS.QueriesDb.Library/Migrations/DbContextApplicationQueriesModelSnapshot.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -using System; -using CleanArchitectureCQRS.QueriesDb.Library.Database; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace CleanArchitectureCQRS.QueriesDb.Library.Migrations -{ - [DbContext(typeof(DbContextApplicationQueries))] - partial class DbContextApplicationQueriesModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("CleanArchitectureCQRS.Domain.Library.Aggregates.People.Entities.Person", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("BusinessId") - .HasColumnType("uniqueidentifier"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("People", "Test"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Src/4.EndPoints/WebApi.EndPoints/WebApiBase/Controllers/BaseController.cs b/Src/4.EndPoints/WebApi.EndPoints/BaseWebApi/Controllers/BaseController.cs similarity index 98% rename from Src/4.EndPoints/WebApi.EndPoints/WebApiBase/Controllers/BaseController.cs rename to Src/4.EndPoints/WebApi.EndPoints/BaseWebApi/Controllers/BaseController.cs index cb4d68c..2f64565 100644 --- a/Src/4.EndPoints/WebApi.EndPoints/WebApiBase/Controllers/BaseController.cs +++ b/Src/4.EndPoints/WebApi.EndPoints/BaseWebApi/Controllers/BaseController.cs @@ -7,7 +7,7 @@ using System.Net; using WebApi.EndPoints.DIContainers; -namespace WebApi.EndPoints.WebApiBase.Controllers; +namespace WebApi.EndPoints.BaseWebApi.Controllers; [ApiController] [Route("api/[controller]")] diff --git a/Src/4.EndPoints/WebApi.EndPoints/Controllers/Account/AccountController.cs b/Src/4.EndPoints/WebApi.EndPoints/Controllers/Account/AccountController.cs new file mode 100644 index 0000000..0b80db9 --- /dev/null +++ b/Src/4.EndPoints/WebApi.EndPoints/Controllers/Account/AccountController.cs @@ -0,0 +1,11 @@ +using MediatR; +using WebApi.EndPoints.BaseWebApi.Controllers; + +namespace WebApi.EndPoints.Controllers.Account; + +public class AccountController : BaseController +{ + public AccountController(IMediator mediator) : base(mediator) + { + } +} \ No newline at end of file diff --git a/Src/4.EndPoints/WebApi.EndPoints/Controllers/CatalogItemController.cs b/Src/4.EndPoints/WebApi.EndPoints/Controllers/CatalogItemController.cs index 43bded1..c0ec8cf 100644 --- a/Src/4.EndPoints/WebApi.EndPoints/Controllers/CatalogItemController.cs +++ b/Src/4.EndPoints/WebApi.EndPoints/Controllers/CatalogItemController.cs @@ -1,17 +1,14 @@ using MediatR; using Microsoft.AspNetCore.Mvc; +using WebApi.EndPoints.BaseWebApi.Controllers; namespace WebApi.EndPoints.Controllers; [ApiController] [Route("[controller]")] -public class CatalogItemController : ControllerBase +public class CatalogItemController : BaseController { - private readonly IMediator _mediator; - - public CatalogItemController(IMediator mediator) + public CatalogItemController(IMediator mediator) : base(mediator) { - _mediator = mediator; } - } diff --git a/Src/4.EndPoints/WebApi.EndPoints/Controllers/HomeController.cs b/Src/4.EndPoints/WebApi.EndPoints/Controllers/HomeController.cs index 7787d9c..2e530b9 100644 --- a/Src/4.EndPoints/WebApi.EndPoints/Controllers/HomeController.cs +++ b/Src/4.EndPoints/WebApi.EndPoints/Controllers/HomeController.cs @@ -1,27 +1,11 @@ -using Microsoft.AspNetCore.Mvc; +using MediatR; +using WebApi.EndPoints.BaseWebApi.Controllers; -namespace WebApi.EndPoints.Controllers +namespace WebApi.EndPoints.Controllers; + +public class HomeController : BaseController { - [ApiController] - [Route("[controller]")] - public class HomeController : ControllerBase + public HomeController(IMediator mediator) : base(mediator) { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" - }; - - private readonly ILogger _logger; - - public HomeController(ILogger logger) - { - _logger = logger; - } - - [HttpGet(Name = "GetWeatherForecast")] - public IEnumerable Get() - { - return Enumerable.Range(1, 5).Select(index => $"{index}").ToArray(); - } } } diff --git a/Src/4.EndPoints/WebApi.EndPoints/Controllers/PersonController.cs b/Src/4.EndPoints/WebApi.EndPoints/Controllers/PersonController.cs index d82fcb0..2d381e4 100644 --- a/Src/4.EndPoints/WebApi.EndPoints/Controllers/PersonController.cs +++ b/Src/4.EndPoints/WebApi.EndPoints/Controllers/PersonController.cs @@ -7,7 +7,7 @@ using CleanArchitectureCQRS.Application.Library.Aggregates.People.Queries.GetById; using MediatR; using Microsoft.AspNetCore.Mvc; -using WebApi.EndPoints.WebApiBase.Controllers; +using WebApi.EndPoints.BaseWebApi.Controllers; namespace WebApi.EndPoints.Controllers; @@ -18,7 +18,7 @@ public PersonController(IMediator mediator) : base(mediator) } [HttpPost] - public async Task Create(CreatePerson command) => await Create(command); + public async Task Create(CreatePerson command) => await Create(command); [HttpDelete] public async Task Delete(int id) @@ -46,12 +46,12 @@ public async Task GetAll() { return await Get>(new GetAllPerson()); } - - + + [HttpGet("GetById")] public async Task GetById(GetPersonById getPerson) => await Get(getPerson); - - + + [HttpPut("ChangePassword")] public async Task ChangePassword(ChangePassword command) { diff --git a/Src/4.EndPoints/WebApi.EndPoints/Controllers/Security/RoleController.cs b/Src/4.EndPoints/WebApi.EndPoints/Controllers/Security/RoleController.cs new file mode 100644 index 0000000..8a7994c --- /dev/null +++ b/Src/4.EndPoints/WebApi.EndPoints/Controllers/Security/RoleController.cs @@ -0,0 +1,11 @@ +using MediatR; +using WebApi.EndPoints.BaseWebApi.Controllers; + +namespace WebApi.EndPoints.Controllers.Security; + +public class RoleController : BaseController +{ + public RoleController(IMediator mediator) : base(mediator) + { + } +} diff --git a/Src/4.EndPoints/WebApi.EndPoints/Controllers/UserController.cs b/Src/4.EndPoints/WebApi.EndPoints/Controllers/Security/UserController.cs similarity index 73% rename from Src/4.EndPoints/WebApi.EndPoints/Controllers/UserController.cs rename to Src/4.EndPoints/WebApi.EndPoints/Controllers/Security/UserController.cs index f78234e..2ed4bfb 100644 --- a/Src/4.EndPoints/WebApi.EndPoints/Controllers/UserController.cs +++ b/Src/4.EndPoints/WebApi.EndPoints/Controllers/Security/UserController.cs @@ -1,16 +1,12 @@ -using CleanArchitectureCQRS.Application.Library.Aggregates.People.Commands.CreatePerson; -using CleanArchitectureCQRS.Application.Library.Aggregates.People.Queries.GetAllPerson; -using CleanArchitectureCQRS.Application.Library.Aggregates.People.Queries.GetById; -using CleanArchitectureCQRS.Application.Library.Aggregates.Users.Commands.CreateUser; +using CleanArchitectureCQRS.Application.Library.Aggregates.Users.Commands.CreateUser; using CleanArchitectureCQRS.Application.Library.Aggregates.Users.Queires.GetAllUser; using CleanArchitectureCQRS.Application.Library.Aggregates.Users.Queires.GetUserById; -using CleanArchitectureCQRS.Domain.Library.Aggregates.Users.DomainEvents; using MediatR; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; -using WebApi.EndPoints.WebApiBase.Controllers; +using WebApi.EndPoints.BaseWebApi.Controllers; -namespace WebApi.EndPoints.Controllers; +namespace WebApi.EndPoints.Controllers.Security; public class UserController : BaseController {