From 9b1712105ab7ff49e24734176a2df654701ac556 Mon Sep 17 00:00:00 2001 From: Mobin Barfi Date: Mon, 19 Aug 2024 19:10:55 +0330 Subject: [PATCH] refactor: refactor transaction related apis --- .../DTOs/Account/AccountCsvModel.cs | 10 +- .../GetAllTransactionsResponse.cs | 2 +- .../TransactionCsvModel.cs | 28 +- .../Interfaces/Services/IAccountService.cs | 2 +- .../Services/ITransactionService.cs | 4 +- src/Application/Mappers/AccountMapper.cs | 10 +- src/Application/Mappers/TransactionMapper.cs | 2 +- src/Application/Services/AccountService.cs | 12 +- .../SharedService/CsvReaderService.cs | 1 - .../Services/TransactionService.cs | 5 +- src/Domain/Entities/Account.cs | 18 +- src/Domain/Entities/Transaction.cs | 10 +- .../20240814092051_CompleteUser.Designer.cs | 307 ------- ...17193825_Accounts-Transactions.Designer.cs | 414 --------- .../20240817193825_Accounts-Transactions.cs | 138 --- .../20240818091853_CastIdsToLong.cs | 159 ---- ...9152618_accounts-transactions.Designer.cs} | 835 +++++++++--------- ...> 20240819152618_accounts-transactions.cs} | 540 ++++++----- .../ApplicationDbContextModelSnapshot.cs | 829 ++++++++--------- ...Repository.cs => RoleManagerRepository.cs} | 4 +- ...Repository.cs => UserManagerRepository.cs} | 4 +- src/Web/Controllers/AccountController.cs | 4 +- src/Web/Controllers/TransactionController.cs | 4 +- src/Web/DTOs/Account/AccountDto.cs | 2 +- src/Web/Mappers/AccountMapper.cs | 10 +- src/Web/Mappers/TransactionMapper.cs | 2 +- src/Web/Program.cs | 4 +- 27 files changed, 1211 insertions(+), 2149 deletions(-) rename src/Application/DTOs/{TransactionCsv => Transaction}/GetAllTransactionsResponse.cs (71%) rename src/Application/DTOs/{TransactionCsv => Transaction}/TransactionCsvModel.cs (88%) delete mode 100644 src/Infrastructure/Migrations/20240814092051_CompleteUser.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240817193825_Accounts-Transactions.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240817193825_Accounts-Transactions.cs delete mode 100644 src/Infrastructure/Migrations/20240818091853_CastIdsToLong.cs rename src/Infrastructure/Migrations/{20240818091853_CastIdsToLong.Designer.cs => 20240819152618_accounts-transactions.Designer.cs} (91%) rename src/Infrastructure/Migrations/{20240814092051_CompleteUser.cs => 20240819152618_accounts-transactions.cs} (72%) rename src/Infrastructure/Repositories/{RoleManagerRepositoryRepository.cs => RoleManagerRepository.cs} (72%) rename src/Infrastructure/Repositories/{UserManagerRepositoryRepository.cs => UserManagerRepository.cs} (94%) diff --git a/src/Application/DTOs/Account/AccountCsvModel.cs b/src/Application/DTOs/Account/AccountCsvModel.cs index 0ecccac..e1a09ca 100644 --- a/src/Application/DTOs/Account/AccountCsvModel.cs +++ b/src/Application/DTOs/Account/AccountCsvModel.cs @@ -2,14 +2,14 @@ public class AccountCsvModel { - public long AccountId { get; set; } - public long CardId { get; set; } - public string Iban { get; set; } = string.Empty; + public long AccountID { get; set; } + public long CardID { get; set; } + public string IBAN { get; set; } = string.Empty; public string AccountType { get; set; } = string.Empty; public string BranchTelephone { get; set; } = string.Empty; - public string BranchAddress { get; set; } = string.Empty; + public string BranchAdress { get; set; } = string.Empty; public string BranchName { get; set; } = string.Empty; public string OwnerName { get; set; } = string.Empty; public string OwnerLastName { get; set; } = string.Empty; - public string OwnerId { get; set; } = string.Empty; + public long OwnerID { get; set; } } \ No newline at end of file diff --git a/src/Application/DTOs/TransactionCsv/GetAllTransactionsResponse.cs b/src/Application/DTOs/Transaction/GetAllTransactionsResponse.cs similarity index 71% rename from src/Application/DTOs/TransactionCsv/GetAllTransactionsResponse.cs rename to src/Application/DTOs/Transaction/GetAllTransactionsResponse.cs index 005cf3c..921d04a 100644 --- a/src/Application/DTOs/TransactionCsv/GetAllTransactionsResponse.cs +++ b/src/Application/DTOs/Transaction/GetAllTransactionsResponse.cs @@ -1,4 +1,4 @@ -namespace Application.DTOs.TransactionCsv; +namespace Application.DTOs.Transaction; public class GetAllTransactionsResponse { diff --git a/src/Application/DTOs/TransactionCsv/TransactionCsvModel.cs b/src/Application/DTOs/Transaction/TransactionCsvModel.cs similarity index 88% rename from src/Application/DTOs/TransactionCsv/TransactionCsvModel.cs rename to src/Application/DTOs/Transaction/TransactionCsvModel.cs index 1b1cac9..a5b2596 100644 --- a/src/Application/DTOs/TransactionCsv/TransactionCsvModel.cs +++ b/src/Application/DTOs/Transaction/TransactionCsvModel.cs @@ -1,15 +1,15 @@ -using Application.Services.SharedService; -using CsvHelper.Configuration.Attributes; - -namespace Application.DTOs.TransactionCsv; - -public class TransactionCsvModel -{ - public long TransactionID { get; set; } - public long SourceAcount { get; set; } - public long DestiantionAccount { get; set; } - public decimal Amount { get; set; } - [TypeConverter(typeof(PersianDateConverter))] - public DateTime Date { get; set; } - public string Type { get; set; } = string.Empty; +using Application.Services.SharedService; +using CsvHelper.Configuration.Attributes; + +namespace Application.DTOs.Transaction; + +public class TransactionCsvModel +{ + public long TransactionID { get; set; } + public long SourceAcount { get; set; } + public long DestiantionAccount { get; set; } + public decimal Amount { get; set; } + [TypeConverter(typeof(PersianDateConverter))] + public DateTime Date { get; set; } + public string Type { get; set; } = string.Empty; } \ No newline at end of file diff --git a/src/Application/Interfaces/Services/IAccountService.cs b/src/Application/Interfaces/Services/IAccountService.cs index 96228e4..0dcb169 100644 --- a/src/Application/Interfaces/Services/IAccountService.cs +++ b/src/Application/Interfaces/Services/IAccountService.cs @@ -9,5 +9,5 @@ public interface IAccountService Task AddAccountsFromCsvAsync(string filePath); Task GetAccountByIdAsync(long accountId); Task>> GetTransactionsByUserId(long accountId); - Task> GetAllAccounts(); + Task> GetAllAccountsAsync(); } \ No newline at end of file diff --git a/src/Application/Interfaces/Services/ITransactionService.cs b/src/Application/Interfaces/Services/ITransactionService.cs index 3b453dd..f791634 100644 --- a/src/Application/Interfaces/Services/ITransactionService.cs +++ b/src/Application/Interfaces/Services/ITransactionService.cs @@ -1,10 +1,10 @@ using Application.DTOs; -using Application.DTOs.TransactionCsv; +using Application.DTOs.Transaction; namespace Application.Interfaces.Services; public interface ITransactionService { Task AddTransactionsFromCsvAsync(string filePath); - Task> GetAllTransactions(); + Task> GetAllTransactionsAsync(); } \ No newline at end of file diff --git a/src/Application/Mappers/AccountMapper.cs b/src/Application/Mappers/AccountMapper.cs index 34934db..414d1f0 100644 --- a/src/Application/Mappers/AccountMapper.cs +++ b/src/Application/Mappers/AccountMapper.cs @@ -11,16 +11,16 @@ public static GetAllAccountsResponse ToGetAllAccountsResponse(this List { Accounts = accounts.Select(account => new AccountCsvModel { - AccountId = account.AccountId, - CardId = account.CardId, - Iban = account.Iban, + AccountID = account.AccountId, + CardID = account.CardId, + IBAN = account.Iban, AccountType = account.AccountType, BranchTelephone = account.BranchTelephone, - BranchAddress = account.BranchAddress, + BranchAdress = account.BranchAddress, BranchName = account.BranchName, OwnerName = account.OwnerName, OwnerLastName = account.OwnerLastName, - OwnerId = account.OwnerId + OwnerID = account.OwnerId }).ToList() }; } diff --git a/src/Application/Mappers/TransactionMapper.cs b/src/Application/Mappers/TransactionMapper.cs index 4cd65a0..9cf22fe 100644 --- a/src/Application/Mappers/TransactionMapper.cs +++ b/src/Application/Mappers/TransactionMapper.cs @@ -1,4 +1,4 @@ -using Application.DTOs.TransactionCsv; +using Application.DTOs.Transaction; using Domain.Entities; namespace Application.Mappers; diff --git a/src/Application/Services/AccountService.cs b/src/Application/Services/AccountService.cs index 55b7055..7bae7cc 100644 --- a/src/Application/Services/AccountService.cs +++ b/src/Application/Services/AccountService.cs @@ -24,16 +24,16 @@ public async Task AddAccountsFromCsvAsync(string filePath) var accounts = accountCsvModels.Select(csvModel => new Account { - AccountId = csvModel.AccountId, - CardId = csvModel.CardId, - Iban = csvModel.Iban, + AccountId = csvModel.AccountID, + CardId = csvModel.CardID, + Iban = csvModel.IBAN, AccountType = csvModel.AccountType, BranchTelephone = csvModel.BranchTelephone, - BranchAddress = csvModel.BranchAddress, + BranchAddress = csvModel.BranchAdress, BranchName = csvModel.BranchName, OwnerName = csvModel.OwnerName, OwnerLastName = csvModel.OwnerLastName, - OwnerId = csvModel.OwnerId + OwnerId = csvModel.OwnerID }).ToList(); await _accountRepository.CreateBulkAsync(accounts); @@ -57,7 +57,7 @@ public async Task>> GetTransactionsByUserId(long accoun return Result>.Ok(transactions); } - public async Task> GetAllAccounts() + public async Task> GetAllAccountsAsync() { try { diff --git a/src/Application/Services/SharedService/CsvReaderService.cs b/src/Application/Services/SharedService/CsvReaderService.cs index 6217f9d..c12e326 100644 --- a/src/Application/Services/SharedService/CsvReaderService.cs +++ b/src/Application/Services/SharedService/CsvReaderService.cs @@ -1,5 +1,4 @@ using System.Globalization; -using Application.DTOs.TransactionCsv; using CsvHelper; using CsvHelper.Configuration; diff --git a/src/Application/Services/TransactionService.cs b/src/Application/Services/TransactionService.cs index 5601c1c..e258c76 100644 --- a/src/Application/Services/TransactionService.cs +++ b/src/Application/Services/TransactionService.cs @@ -1,11 +1,10 @@ using Application.DTOs; -using Application.DTOs.TransactionCsv; +using Application.DTOs.Transaction; using Application.Interfaces; using Application.Interfaces.Services; using Application.Mappers; using Application.Services.SharedService; using Domain.Entities; -using Application.DTOs.TransactionCsv; using Application.Interfaces.Repositories; namespace Application.Services; @@ -36,7 +35,7 @@ public async Task AddTransactionsFromCsvAsync(string filePath) await _transactionRepository.CreateBulkAsync(transactions); } - public async Task> GetAllTransactions() + public async Task> GetAllTransactionsAsync() { try { diff --git a/src/Domain/Entities/Account.cs b/src/Domain/Entities/Account.cs index db92794..c32ac84 100644 --- a/src/Domain/Entities/Account.cs +++ b/src/Domain/Entities/Account.cs @@ -10,28 +10,26 @@ public class Account public long CardId { get; set; } [MaxLength(50)] - public string Iban { get; set; } = string.Empty; + public string Iban { get; set; } = String.Empty; [MaxLength(50)] - public string AccountType { get; set; } = string.Empty; + public string AccountType { get; set; } = String.Empty; [MaxLength(20)] - public string BranchTelephone { get; set; } = string.Empty; + public string BranchTelephone { get; set; } = String.Empty; [MaxLength(150)] - public string BranchAddress { get; set; } = string.Empty; + public string BranchAddress { get; set; } = String.Empty; [MaxLength(50)] - public string BranchName { get; set; } = string.Empty; + public string BranchName { get; set; } = String.Empty; [MaxLength(50)] - public string OwnerName { get; set; } = string.Empty; + public string OwnerName { get; set; } = String.Empty; [MaxLength(50)] - public string OwnerLastName { get; set; } = string.Empty; - - [MaxLength(50)] - public string OwnerId { get; set; } = string.Empty; + public string OwnerLastName { get; set; } = String.Empty; + public long OwnerId { get; set; } public List SourceTransactions { get; set; } = new(); public List DestinationTransactions { get; set; } = new(); diff --git a/src/Domain/Entities/Transaction.cs b/src/Domain/Entities/Transaction.cs index 831e247..e44783a 100644 --- a/src/Domain/Entities/Transaction.cs +++ b/src/Domain/Entities/Transaction.cs @@ -1,15 +1,19 @@ -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Diagnostics.CodeAnalysis; namespace Domain.Entities; [Table("Transactions")] public class Transaction { + [Key] public long TransactionId { get; set; } public long SourceAccountId { get; set; } - public Account SourceAccount { get; set; } + public Account? SourceAccount { get; set; } public long DestinationAccountId { get; set; } - public Account DestinationAccount { get; set; } + public Account? DestinationAccount { get; set; } public decimal Amount { get; set; } public DateTime Date { get; set; } + [MaxLength(50)] public string Type { get; set; } = String.Empty; } \ No newline at end of file diff --git a/src/Infrastructure/Migrations/20240814092051_CompleteUser.Designer.cs b/src/Infrastructure/Migrations/20240814092051_CompleteUser.Designer.cs deleted file mode 100644 index 8ad4fdf..0000000 --- a/src/Infrastructure/Migrations/20240814092051_CompleteUser.Designer.cs +++ /dev/null @@ -1,307 +0,0 @@ -// -using System; -using Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240814092051_CompleteUser")] - partial class CompleteUser - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Infrastructure.Entities.AppUser", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - - b.HasData( - new - { - Id = "502db14d-ec3d-42f2-a56c-c14ad1217dda", - Name = "Admin", - NormalizedName = "ADMIN" - }, - new - { - Id = "1d283a73-9ec4-4897-a709-2f21f1347cd6", - Name = "DataAdmin", - NormalizedName = "DATAADMIN" - }, - new - { - Id = "15b3c37c-d76a-4b52-a53f-5ec7e65bedcc", - Name = "DataAnalyst", - NormalizedName = "DATAANALYST" - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("text"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - 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("Infrastructure.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Infrastructure.Entities.AppUser", 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("Infrastructure.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Infrastructure.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240817193825_Accounts-Transactions.Designer.cs b/src/Infrastructure/Migrations/20240817193825_Accounts-Transactions.Designer.cs deleted file mode 100644 index 144d9e4..0000000 --- a/src/Infrastructure/Migrations/20240817193825_Accounts-Transactions.Designer.cs +++ /dev/null @@ -1,414 +0,0 @@ -// -using System; -using Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240817193825_Accounts-Transactions")] - partial class AccountsTransactions - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Domain.Entities.Account", b => - { - b.Property("AccountId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AccountId")); - - b.Property("AccountType") - .IsRequired() - .HasColumnType("text"); - - b.Property("BranchAddress") - .IsRequired() - .HasColumnType("text"); - - b.Property("BranchName") - .IsRequired() - .HasColumnType("text"); - - b.Property("BranchTelephone") - .IsRequired() - .HasColumnType("text"); - - b.Property("CardId") - .HasColumnType("integer"); - - b.Property("Iban") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerLastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("AccountId"); - - b.ToTable("Accounts"); - }); - - modelBuilder.Entity("Domain.Entities.AppUser", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Domain.Entities.Transaction", b => - { - b.Property("TransactionId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransactionId")); - - b.Property("Amount") - .HasColumnType("numeric"); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("DestinationAccountId") - .HasColumnType("integer"); - - b.Property("SourceAccountId") - .HasColumnType("integer"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("TransactionId"); - - b.HasIndex("DestinationAccountId"); - - b.HasIndex("SourceAccountId"); - - b.ToTable("Transactions"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - - b.HasData( - new - { - Id = "0a8ca877-f408-4d10-806f-1714e41b0186", - Name = "Admin", - NormalizedName = "ADMIN" - }, - new - { - Id = "fa9ffeed-788f-40cd-a86b-3e5ad7a03e0b", - Name = "DataAdmin", - NormalizedName = "DATAADMIN" - }, - new - { - Id = "913a4192-89c6-4d8e-873c-52d9695f8d59", - Name = "DataAnalyst", - NormalizedName = "DATAANALYST" - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("text"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Domain.Entities.Transaction", b => - { - b.HasOne("Domain.Entities.Account", "DestinationAccount") - .WithMany("DestinationTransactions") - .HasForeignKey("DestinationAccountId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Domain.Entities.Account", "SourceAccount") - .WithMany("SourceTransactions") - .HasForeignKey("SourceAccountId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("DestinationAccount"); - - b.Navigation("SourceAccount"); - }); - - 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("Domain.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Domain.Entities.AppUser", 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("Domain.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Domain.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Domain.Entities.Account", b => - { - b.Navigation("DestinationTransactions"); - - b.Navigation("SourceTransactions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240817193825_Accounts-Transactions.cs b/src/Infrastructure/Migrations/20240817193825_Accounts-Transactions.cs deleted file mode 100644 index b2e7c6b..0000000 --- a/src/Infrastructure/Migrations/20240817193825_Accounts-Transactions.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace Infrastructure.Migrations -{ - /// - public partial class AccountsTransactions : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "15b3c37c-d76a-4b52-a53f-5ec7e65bedcc"); - - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "1d283a73-9ec4-4897-a709-2f21f1347cd6"); - - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "502db14d-ec3d-42f2-a56c-c14ad1217dda"); - - migrationBuilder.CreateTable( - name: "Accounts", - columns: table => new - { - AccountId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - CardId = table.Column(type: "integer", nullable: false), - Iban = table.Column(type: "text", nullable: false), - AccountType = table.Column(type: "text", nullable: false), - BranchTelephone = table.Column(type: "text", nullable: false), - BranchAddress = table.Column(type: "text", nullable: false), - BranchName = table.Column(type: "text", nullable: false), - OwnerName = table.Column(type: "text", nullable: false), - OwnerLastName = table.Column(type: "text", nullable: false), - OwnerId = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Accounts", x => x.AccountId); - }); - - migrationBuilder.CreateTable( - name: "Transactions", - columns: table => new - { - TransactionId = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - SourceAccountId = table.Column(type: "integer", nullable: false), - DestinationAccountId = table.Column(type: "integer", nullable: false), - Amount = table.Column(type: "numeric", nullable: false), - Date = table.Column(type: "timestamp with time zone", nullable: false), - Type = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Transactions", x => x.TransactionId); - table.ForeignKey( - name: "FK_Transactions_Accounts_DestinationAccountId", - column: x => x.DestinationAccountId, - principalTable: "Accounts", - principalColumn: "AccountId", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_Transactions_Accounts_SourceAccountId", - column: x => x.SourceAccountId, - principalTable: "Accounts", - principalColumn: "AccountId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.InsertData( - table: "AspNetRoles", - columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, - values: new object[,] - { - { "0a8ca877-f408-4d10-806f-1714e41b0186", null, "Admin", "ADMIN" }, - { "913a4192-89c6-4d8e-873c-52d9695f8d59", null, "DataAnalyst", "DATAANALYST" }, - { "fa9ffeed-788f-40cd-a86b-3e5ad7a03e0b", null, "DataAdmin", "DATAADMIN" } - }); - - migrationBuilder.CreateIndex( - name: "IX_Transactions_DestinationAccountId", - table: "Transactions", - column: "DestinationAccountId"); - - migrationBuilder.CreateIndex( - name: "IX_Transactions_SourceAccountId", - table: "Transactions", - column: "SourceAccountId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Transactions"); - - migrationBuilder.DropTable( - name: "Accounts"); - - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "0a8ca877-f408-4d10-806f-1714e41b0186"); - - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "913a4192-89c6-4d8e-873c-52d9695f8d59"); - - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "fa9ffeed-788f-40cd-a86b-3e5ad7a03e0b"); - - migrationBuilder.InsertData( - table: "AspNetRoles", - columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, - values: new object[,] - { - { "15b3c37c-d76a-4b52-a53f-5ec7e65bedcc", null, "DataAnalyst", "DATAANALYST" }, - { "1d283a73-9ec4-4897-a709-2f21f1347cd6", null, "DataAdmin", "DATAADMIN" }, - { "502db14d-ec3d-42f2-a56c-c14ad1217dda", null, "Admin", "ADMIN" } - }); - } - } -} diff --git a/src/Infrastructure/Migrations/20240818091853_CastIdsToLong.cs b/src/Infrastructure/Migrations/20240818091853_CastIdsToLong.cs deleted file mode 100644 index 7042761..0000000 --- a/src/Infrastructure/Migrations/20240818091853_CastIdsToLong.cs +++ /dev/null @@ -1,159 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace Infrastructure.Migrations -{ - /// - public partial class CastIdsToLong : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "0a8ca877-f408-4d10-806f-1714e41b0186"); - - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "913a4192-89c6-4d8e-873c-52d9695f8d59"); - - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "fa9ffeed-788f-40cd-a86b-3e5ad7a03e0b"); - - migrationBuilder.AlterColumn( - name: "SourceAccountId", - table: "Transactions", - type: "bigint", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AlterColumn( - name: "DestinationAccountId", - table: "Transactions", - type: "bigint", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AlterColumn( - name: "TransactionId", - table: "Transactions", - type: "bigint", - nullable: false, - oldClrType: typeof(int), - oldType: "integer") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "CardId", - table: "Accounts", - type: "bigint", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AlterColumn( - name: "AccountId", - table: "Accounts", - type: "bigint", - nullable: false, - oldClrType: typeof(int), - oldType: "integer") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.InsertData( - table: "AspNetRoles", - columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, - values: new object[,] - { - { "021da0cb-1048-4551-9858-90c98ee66289", null, "DataAnalyst", "DATAANALYST" }, - { "2d28da36-33b9-4ac1-b08f-50b4dd6855d2", null, "DataAdmin", "DATAADMIN" }, - { "bef465d8-3d0e-469f-8b45-5f9be9c40f66", null, "Admin", "ADMIN" } - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "021da0cb-1048-4551-9858-90c98ee66289"); - - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "2d28da36-33b9-4ac1-b08f-50b4dd6855d2"); - - migrationBuilder.DeleteData( - table: "AspNetRoles", - keyColumn: "Id", - keyValue: "bef465d8-3d0e-469f-8b45-5f9be9c40f66"); - - migrationBuilder.AlterColumn( - name: "SourceAccountId", - table: "Transactions", - type: "integer", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint"); - - migrationBuilder.AlterColumn( - name: "DestinationAccountId", - table: "Transactions", - type: "integer", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint"); - - migrationBuilder.AlterColumn( - name: "TransactionId", - table: "Transactions", - type: "integer", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "CardId", - table: "Accounts", - type: "integer", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint"); - - migrationBuilder.AlterColumn( - name: "AccountId", - table: "Accounts", - type: "integer", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.InsertData( - table: "AspNetRoles", - columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, - values: new object[,] - { - { "0a8ca877-f408-4d10-806f-1714e41b0186", null, "Admin", "ADMIN" }, - { "913a4192-89c6-4d8e-873c-52d9695f8d59", null, "DataAnalyst", "DATAANALYST" }, - { "fa9ffeed-788f-40cd-a86b-3e5ad7a03e0b", null, "DataAdmin", "DATAADMIN" } - }); - } - } -} diff --git a/src/Infrastructure/Migrations/20240818091853_CastIdsToLong.Designer.cs b/src/Infrastructure/Migrations/20240819152618_accounts-transactions.Designer.cs similarity index 91% rename from src/Infrastructure/Migrations/20240818091853_CastIdsToLong.Designer.cs rename to src/Infrastructure/Migrations/20240819152618_accounts-transactions.Designer.cs index f7c5d9f..aac0f18 100644 --- a/src/Infrastructure/Migrations/20240818091853_CastIdsToLong.Designer.cs +++ b/src/Infrastructure/Migrations/20240819152618_accounts-transactions.Designer.cs @@ -1,414 +1,421 @@ -// -using System; -using Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240818091853_CastIdsToLong")] - partial class CastIdsToLong - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Domain.Entities.Account", b => - { - b.Property("AccountId") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AccountId")); - - b.Property("AccountType") - .IsRequired() - .HasColumnType("text"); - - b.Property("BranchAddress") - .IsRequired() - .HasColumnType("text"); - - b.Property("BranchName") - .IsRequired() - .HasColumnType("text"); - - b.Property("BranchTelephone") - .IsRequired() - .HasColumnType("text"); - - b.Property("CardId") - .HasColumnType("bigint"); - - b.Property("Iban") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerLastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("AccountId"); - - b.ToTable("Accounts"); - }); - - modelBuilder.Entity("Domain.Entities.AppUser", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Domain.Entities.Transaction", b => - { - b.Property("TransactionId") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransactionId")); - - b.Property("Amount") - .HasColumnType("numeric"); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("DestinationAccountId") - .HasColumnType("bigint"); - - b.Property("SourceAccountId") - .HasColumnType("bigint"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("TransactionId"); - - b.HasIndex("DestinationAccountId"); - - b.HasIndex("SourceAccountId"); - - b.ToTable("Transactions"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - - b.HasData( - new - { - Id = "bef465d8-3d0e-469f-8b45-5f9be9c40f66", - Name = "Admin", - NormalizedName = "ADMIN" - }, - new - { - Id = "2d28da36-33b9-4ac1-b08f-50b4dd6855d2", - Name = "DataAdmin", - NormalizedName = "DATAADMIN" - }, - new - { - Id = "021da0cb-1048-4551-9858-90c98ee66289", - Name = "DataAnalyst", - NormalizedName = "DATAANALYST" - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("text"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Domain.Entities.Transaction", b => - { - b.HasOne("Domain.Entities.Account", "DestinationAccount") - .WithMany("DestinationTransactions") - .HasForeignKey("DestinationAccountId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Domain.Entities.Account", "SourceAccount") - .WithMany("SourceTransactions") - .HasForeignKey("SourceAccountId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("DestinationAccount"); - - b.Navigation("SourceAccount"); - }); - - 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("Domain.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Domain.Entities.AppUser", 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("Domain.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Domain.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Domain.Entities.Account", b => - { - b.Navigation("DestinationTransactions"); - - b.Navigation("SourceTransactions"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Infrastructure.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Infrastructure.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240819152618_accounts-transactions")] + partial class accountstransactions + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Domain.Entities.Account", b => + { + b.Property("AccountId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AccountId")); + + b.Property("AccountType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BranchAddress") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("BranchName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BranchTelephone") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("Iban") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OwnerId") + .HasColumnType("bigint"); + + b.Property("OwnerLastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OwnerName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("AccountId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Domain.Entities.AppUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Domain.Entities.Transaction", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransactionId")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("DestinationAccountId") + .HasColumnType("bigint"); + + b.Property("SourceAccountId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("TransactionId"); + + b.HasIndex("DestinationAccountId"); + + b.HasIndex("SourceAccountId"); + + b.ToTable("Transactions"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + + b.HasData( + new + { + Id = "5a15c66d-6214-4dbb-a00d-10a4f7ca4cf8", + Name = "Admin", + NormalizedName = "ADMIN" + }, + new + { + Id = "46a9f2ed-8738-448a-9ca9-3afa00eee4ff", + Name = "DataAdmin", + NormalizedName = "DATAADMIN" + }, + new + { + Id = "48732a60-c9aa-4aec-9ef3-b880ab162088", + Name = "DataAnalyst", + NormalizedName = "DATAANALYST" + }); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Domain.Entities.Transaction", b => + { + b.HasOne("Domain.Entities.Account", "DestinationAccount") + .WithMany("DestinationTransactions") + .HasForeignKey("DestinationAccountId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Domain.Entities.Account", "SourceAccount") + .WithMany("SourceTransactions") + .HasForeignKey("SourceAccountId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DestinationAccount"); + + b.Navigation("SourceAccount"); + }); + + 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("Domain.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Domain.Entities.AppUser", 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("Domain.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Domain.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Domain.Entities.Account", b => + { + b.Navigation("DestinationTransactions"); + + b.Navigation("SourceTransactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Infrastructure/Migrations/20240814092051_CompleteUser.cs b/src/Infrastructure/Migrations/20240819152618_accounts-transactions.cs similarity index 72% rename from src/Infrastructure/Migrations/20240814092051_CompleteUser.cs rename to src/Infrastructure/Migrations/20240819152618_accounts-transactions.cs index e57b5ed..90fe19d 100644 --- a/src/Infrastructure/Migrations/20240814092051_CompleteUser.cs +++ b/src/Infrastructure/Migrations/20240819152618_accounts-transactions.cs @@ -1,237 +1,303 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace Infrastructure.Migrations -{ - /// - public partial class CompleteUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AspNetRoles", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - FirstName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - LastName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - EmailConfirmed = table.Column(type: "boolean", nullable: false), - PasswordHash = table.Column(type: "text", nullable: true), - SecurityStamp = table.Column(type: "text", nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true), - PhoneNumber = table.Column(type: "text", nullable: true), - PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), - TwoFactorEnabled = table.Column(type: "boolean", nullable: false), - LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), - LockoutEnabled = table.Column(type: "boolean", nullable: false), - AccessFailedCount = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetRoleClaims", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoleId = table.Column(type: "text", nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", 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: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - UserId = table.Column(type: "text", nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", 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: "text", nullable: false), - ProviderKey = table.Column(type: "text", nullable: false), - ProviderDisplayName = table.Column(type: "text", nullable: true), - UserId = table.Column(type: "text", 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: "text", nullable: false), - RoleId = table.Column(type: "text", 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: "text", nullable: false), - LoginProvider = table.Column(type: "text", nullable: false), - Name = table.Column(type: "text", nullable: false), - Value = table.Column(type: "text", 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.InsertData( - table: "AspNetRoles", - columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, - values: new object[,] - { - { "15b3c37c-d76a-4b52-a53f-5ec7e65bedcc", null, "DataAnalyst", "DATAANALYST" }, - { "1d283a73-9ec4-4897-a709-2f21f1347cd6", null, "DataAdmin", "DATAADMIN" }, - { "502db14d-ec3d-42f2-a56c-c14ad1217dda", null, "Admin", "ADMIN" } - }); - - migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName", - unique: true); - - 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); - } - - /// - 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: "AspNetRoles"); - - migrationBuilder.DropTable( - name: "AspNetUsers"); - } - } -} +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace Infrastructure.Migrations +{ + /// + public partial class accountstransactions : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Accounts", + columns: table => new + { + AccountId = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CardId = table.Column(type: "bigint", nullable: false), + Iban = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + AccountType = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + BranchTelephone = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + BranchAddress = table.Column(type: "character varying(150)", maxLength: 150, nullable: false), + BranchName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + OwnerName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + OwnerLastName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + OwnerId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Accounts", x => x.AccountId); + }); + + migrationBuilder.CreateTable( + name: "AspNetRoles", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetUsers", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + FirstName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + LastName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Transactions", + columns: table => new + { + TransactionId = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SourceAccountId = table.Column(type: "bigint", nullable: false), + DestinationAccountId = table.Column(type: "bigint", nullable: false), + Amount = table.Column(type: "numeric", nullable: false), + Date = table.Column(type: "timestamp with time zone", nullable: false), + Type = table.Column(type: "character varying(50)", maxLength: 50, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Transactions", x => x.TransactionId); + table.ForeignKey( + name: "FK_Transactions_Accounts_DestinationAccountId", + column: x => x.DestinationAccountId, + principalTable: "Accounts", + principalColumn: "AccountId", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Transactions_Accounts_SourceAccountId", + column: x => x.SourceAccountId, + principalTable: "Accounts", + principalColumn: "AccountId", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "AspNetRoleClaims", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", 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: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", 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: "text", nullable: false), + ProviderKey = table.Column(type: "text", nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "text", 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: "text", nullable: false), + RoleId = table.Column(type: "text", 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: "text", nullable: false), + LoginProvider = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", 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.InsertData( + table: "AspNetRoles", + columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, + values: new object[,] + { + { "46a9f2ed-8738-448a-9ca9-3afa00eee4ff", null, "DataAdmin", "DATAADMIN" }, + { "48732a60-c9aa-4aec-9ef3-b880ab162088", null, "DataAnalyst", "DATAANALYST" }, + { "5a15c66d-6214-4dbb-a00d-10a4f7ca4cf8", null, "Admin", "ADMIN" } + }); + + migrationBuilder.CreateIndex( + name: "IX_AspNetRoleClaims_RoleId", + table: "AspNetRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "AspNetRoles", + column: "NormalizedName", + unique: true); + + 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); + + migrationBuilder.CreateIndex( + name: "IX_Transactions_DestinationAccountId", + table: "Transactions", + column: "DestinationAccountId"); + + migrationBuilder.CreateIndex( + name: "IX_Transactions_SourceAccountId", + table: "Transactions", + column: "SourceAccountId"); + } + + /// + 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: "Transactions"); + + migrationBuilder.DropTable( + name: "AspNetRoles"); + + migrationBuilder.DropTable( + name: "AspNetUsers"); + + migrationBuilder.DropTable( + name: "Accounts"); + } + } +} diff --git a/src/Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs index 60fd954..d2c3b40 100644 --- a/src/Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1,411 +1,418 @@ -// -using System; -using Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - partial class ApplicationDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Domain.Entities.Account", b => - { - b.Property("AccountId") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AccountId")); - - b.Property("AccountType") - .IsRequired() - .HasColumnType("text"); - - b.Property("BranchAddress") - .IsRequired() - .HasColumnType("text"); - - b.Property("BranchName") - .IsRequired() - .HasColumnType("text"); - - b.Property("BranchTelephone") - .IsRequired() - .HasColumnType("text"); - - b.Property("CardId") - .HasColumnType("bigint"); - - b.Property("Iban") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerLastName") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("AccountId"); - - b.ToTable("Accounts"); - }); - - modelBuilder.Entity("Domain.Entities.AppUser", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Domain.Entities.Transaction", b => - { - b.Property("TransactionId") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransactionId")); - - b.Property("Amount") - .HasColumnType("numeric"); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("DestinationAccountId") - .HasColumnType("bigint"); - - b.Property("SourceAccountId") - .HasColumnType("bigint"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("TransactionId"); - - b.HasIndex("DestinationAccountId"); - - b.HasIndex("SourceAccountId"); - - b.ToTable("Transactions"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - - b.HasData( - new - { - Id = "bef465d8-3d0e-469f-8b45-5f9be9c40f66", - Name = "Admin", - NormalizedName = "ADMIN" - }, - new - { - Id = "2d28da36-33b9-4ac1-b08f-50b4dd6855d2", - Name = "DataAdmin", - NormalizedName = "DATAADMIN" - }, - new - { - Id = "021da0cb-1048-4551-9858-90c98ee66289", - Name = "DataAnalyst", - NormalizedName = "DATAANALYST" - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("text"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Domain.Entities.Transaction", b => - { - b.HasOne("Domain.Entities.Account", "DestinationAccount") - .WithMany("DestinationTransactions") - .HasForeignKey("DestinationAccountId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Domain.Entities.Account", "SourceAccount") - .WithMany("SourceTransactions") - .HasForeignKey("SourceAccountId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("DestinationAccount"); - - b.Navigation("SourceAccount"); - }); - - 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("Domain.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Domain.Entities.AppUser", 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("Domain.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Domain.Entities.AppUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Domain.Entities.Account", b => - { - b.Navigation("DestinationTransactions"); - - b.Navigation("SourceTransactions"); - }); -#pragma warning restore 612, 618 - } - } -} +// +using System; +using Infrastructure.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Infrastructure.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + partial class ApplicationDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Domain.Entities.Account", b => + { + b.Property("AccountId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("AccountId")); + + b.Property("AccountType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BranchAddress") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("BranchName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("BranchTelephone") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("CardId") + .HasColumnType("bigint"); + + b.Property("Iban") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OwnerId") + .HasColumnType("bigint"); + + b.Property("OwnerLastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("OwnerName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("AccountId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Domain.Entities.AppUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Domain.Entities.Transaction", b => + { + b.Property("TransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("TransactionId")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("DestinationAccountId") + .HasColumnType("bigint"); + + b.Property("SourceAccountId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("TransactionId"); + + b.HasIndex("DestinationAccountId"); + + b.HasIndex("SourceAccountId"); + + b.ToTable("Transactions"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + + b.HasData( + new + { + Id = "5a15c66d-6214-4dbb-a00d-10a4f7ca4cf8", + Name = "Admin", + NormalizedName = "ADMIN" + }, + new + { + Id = "46a9f2ed-8738-448a-9ca9-3afa00eee4ff", + Name = "DataAdmin", + NormalizedName = "DATAADMIN" + }, + new + { + Id = "48732a60-c9aa-4aec-9ef3-b880ab162088", + Name = "DataAnalyst", + NormalizedName = "DATAANALYST" + }); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Domain.Entities.Transaction", b => + { + b.HasOne("Domain.Entities.Account", "DestinationAccount") + .WithMany("DestinationTransactions") + .HasForeignKey("DestinationAccountId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Domain.Entities.Account", "SourceAccount") + .WithMany("SourceTransactions") + .HasForeignKey("SourceAccountId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DestinationAccount"); + + b.Navigation("SourceAccount"); + }); + + 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("Domain.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Domain.Entities.AppUser", 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("Domain.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Domain.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Domain.Entities.Account", b => + { + b.Navigation("DestinationTransactions"); + + b.Navigation("SourceTransactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Infrastructure/Repositories/RoleManagerRepositoryRepository.cs b/src/Infrastructure/Repositories/RoleManagerRepository.cs similarity index 72% rename from src/Infrastructure/Repositories/RoleManagerRepositoryRepository.cs rename to src/Infrastructure/Repositories/RoleManagerRepository.cs index f5f098b..db7a740 100644 --- a/src/Infrastructure/Repositories/RoleManagerRepositoryRepository.cs +++ b/src/Infrastructure/Repositories/RoleManagerRepository.cs @@ -4,10 +4,10 @@ namespace Infrastructure.Repositories; -public class RoleManagerRepositoryRepository : IRoleManagerRepository +public class RoleManagerRepository : IRoleManagerRepository { private readonly RoleManager _roleManager; - public RoleManagerRepositoryRepository(RoleManager roleManager) + public RoleManagerRepository(RoleManager roleManager) { _roleManager = roleManager; } diff --git a/src/Infrastructure/Repositories/UserManagerRepositoryRepository.cs b/src/Infrastructure/Repositories/UserManagerRepository.cs similarity index 94% rename from src/Infrastructure/Repositories/UserManagerRepositoryRepository.cs rename to src/Infrastructure/Repositories/UserManagerRepository.cs index 47b2fde..53cc8de 100644 --- a/src/Infrastructure/Repositories/UserManagerRepositoryRepository.cs +++ b/src/Infrastructure/Repositories/UserManagerRepository.cs @@ -5,11 +5,11 @@ namespace Infrastructure.Repositories; -public class UserManagerRepositoryRepository : IUserManagerRepository +public class UserManagerRepository : IUserManagerRepository { private readonly UserManager _userManager; - public UserManagerRepositoryRepository(UserManager userManager) + public UserManagerRepository(UserManager userManager) { _userManager = userManager; } diff --git a/src/Web/Controllers/AccountController.cs b/src/Web/Controllers/AccountController.cs index 3e41d3f..95e2ffa 100644 --- a/src/Web/Controllers/AccountController.cs +++ b/src/Web/Controllers/AccountController.cs @@ -62,10 +62,10 @@ public async Task GetTransactionsByUserId(long accountId) } [HttpGet] - [Authorize] + // [Authorize] public async Task GetAllAccounts() { - var allAccounts = await _accountService.GetAllAccounts(); + var allAccounts = await _accountService.GetAllAccountsAsync(); if (!allAccounts.Succeed) { return BadRequest(Errors.New(nameof(GetAllAccounts), allAccounts.Message)); diff --git a/src/Web/Controllers/TransactionController.cs b/src/Web/Controllers/TransactionController.cs index 53210dc..9618e7e 100644 --- a/src/Web/Controllers/TransactionController.cs +++ b/src/Web/Controllers/TransactionController.cs @@ -36,10 +36,10 @@ public async Task ImportTransactions([FromForm] IFormFile file) } [HttpGet] - [Authorize] + // [Authorize] public async Task GetAllTransactions() { - var allTransactions = await _transactionService.GetAllTransactions(); + var allTransactions = await _transactionService.GetAllTransactionsAsync(); if (!allTransactions.Succeed) { return BadRequest(Errors.New(nameof(GetAllTransactions), allTransactions.Message)); diff --git a/src/Web/DTOs/Account/AccountDto.cs b/src/Web/DTOs/Account/AccountDto.cs index 5ef90c2..4ae0f69 100644 --- a/src/Web/DTOs/Account/AccountDto.cs +++ b/src/Web/DTOs/Account/AccountDto.cs @@ -11,5 +11,5 @@ public class AccountDto public string BranchName { get; set; } = String.Empty; public string OwnerName { get; set; } = String.Empty; public string OwnerLastName { get; set; } = String.Empty; - public string OwnerId { get; set; } = String.Empty; + public long OwnerId { get; set; } } \ No newline at end of file diff --git a/src/Web/Mappers/AccountMapper.cs b/src/Web/Mappers/AccountMapper.cs index 24e6d84..62f1990 100644 --- a/src/Web/Mappers/AccountMapper.cs +++ b/src/Web/Mappers/AccountMapper.cs @@ -27,16 +27,16 @@ public static List ToGotAllAccountsDto(this GetAllAccountsResponse r { return response.Accounts.Select(account => new AccountDto { - AccountId = account.AccountId, - CardId = account.CardId, - Iban = account.Iban, + AccountId = account.AccountID, + CardId = account.CardID, + Iban = account.IBAN, AccountType = account.AccountType, BranchTelephone = account.BranchTelephone, - BranchAddress = account.BranchAddress, + BranchAddress = account.BranchAdress, BranchName = account.BranchName, OwnerName = account.OwnerName, OwnerLastName = account.OwnerLastName, - OwnerId = account.OwnerId + OwnerId = account.OwnerID }).ToList(); } } \ No newline at end of file diff --git a/src/Web/Mappers/TransactionMapper.cs b/src/Web/Mappers/TransactionMapper.cs index c6341b1..c79edf7 100644 --- a/src/Web/Mappers/TransactionMapper.cs +++ b/src/Web/Mappers/TransactionMapper.cs @@ -1,4 +1,4 @@ -using Application.DTOs.TransactionCsv; +using Application.DTOs.Transaction; using Domain.Entities; using Web.DTOs.Transaction; diff --git a/src/Web/Program.cs b/src/Web/Program.cs index 2908271..16bd44e 100644 --- a/src/Web/Program.cs +++ b/src/Web/Program.cs @@ -52,8 +52,8 @@ builder.Services.AddAuthorization(); builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped();