diff --git a/maERP.Server/Migrations/20230725194616_initDatabase.Designer.cs b/maERP.Server/Migrations/20230725194616_initDatabase.Designer.cs new file mode 100644 index 00000000..4c92249f --- /dev/null +++ b/maERP.Server/Migrations/20230725194616_initDatabase.Designer.cs @@ -0,0 +1,1013 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using maERP.Server.Models; + +#nullable disable + +namespace maERP.Server.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20230725194616_initDatabase")] + partial class initDatabase + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + 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 = "02174cf0–9412–4cfe-afbf-59f706d72cf6", + Name = "Admin", + NormalizedName = "ADMIN" + }, + new + { + Id = "341743f0-asd2–42de-afbf-59kmkkmk21ab1", + Name = "User", + NormalizedName = "USER" + }); + }); + + 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); + + b.HasData( + new + { + UserId = "05474ea3–7543-8aef-bcae-33e812c35fc3", + RoleId = "02174cf0–9412–4cfe-afbf-59f706d72cf6" + }); + }); + + 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("maERP.Server.Models.ApplicationUser", 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() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + 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); + + b.HasData( + new + { + Id = "05474ea3–7543-8aef-bcae-33e812c35fc3", + AccessFailedCount = 0, + ConcurrencyStamp = "d04102f6-ba0d-45f3-acc5-a50a25709e4a", + Email = "admin@localhost.com", + EmailConfirmed = false, + FirstName = "Admin", + LastName = "Admin", + LockoutEnabled = false, + NormalizedEmail = "ADMIN@LOCALHOST.COM", + NormalizedUserName = "ADMIN@LOCALHOST.COM", + PasswordHash = "AQAAAAIAAYagAAAAEO+hprJZuHzYVc2E/tGhDzQhzrGD4fS7i2htPWsCGyWMNu/I6YOd02aO1WAtEwRIQA==", + PhoneNumberConfirmed = false, + SecurityStamp = "bbd2a186-408f-42a2-b6bd-6d427ee83176", + TwoFactorEnabled = false, + UserName = "admin@localhost.com" + }); + }); + + modelBuilder.Entity("maERP.Server.Models.Country", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CountryCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Country"); + + b.HasData( + new + { + Id = 1, + CountryCode = "de", + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + Name = "Deutschland" + }, + new + { + Id = 2, + CountryCode = "at", + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + Name = "Österreich" + }, + new + { + Id = 3, + CountryCode = "ch", + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + Name = "Schweiz" + }); + }); + + modelBuilder.Entity("maERP.Server.Models.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CustomerStatus") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.ToTable("Customer"); + }); + + modelBuilder.Entity("maERP.Server.Models.CustomerAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + + b.Property("CountryId") + .HasColumnType("integer"); + + b.Property("CustomerId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("HouseNr") + .IsRequired() + .HasColumnType("text"); + + b.Property("Street") + .IsRequired() + .HasColumnType("text"); + + b.Property("Zip") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CountryId"); + + b.HasIndex("CustomerId"); + + b.ToTable("CustomerAddress"); + }); + + modelBuilder.Entity("maERP.Server.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CustomerId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("maERP.Server.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Asin") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Ean") + .IsRequired() + .HasColumnType("text"); + + b.Property("Msrp") + .HasColumnType("numeric"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.Property("Sku") + .IsRequired() + .HasColumnType("text"); + + b.Property("TaxClassId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Sku") + .IsUnique(); + + b.HasIndex("TaxClassId"); + + b.ToTable("Product"); + }); + + modelBuilder.Entity("maERP.Server.Models.ProductSalesChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("RemoteProductId") + .HasColumnType("integer"); + + b.Property("SalesChannelId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SalesChannelId"); + + b.ToTable("ProductSalesChannel"); + }); + + modelBuilder.Entity("maERP.Server.Models.ProductStock", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("WarehouseId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("WarehouseId"); + + b.ToTable("ProductStock"); + }); + + modelBuilder.Entity("maERP.Server.Models.SalesChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("ExportCustomers") + .HasColumnType("boolean"); + + b.Property("ExportOrders") + .HasColumnType("boolean"); + + b.Property("ExportProducts") + .HasColumnType("boolean"); + + b.Property("ImportCustomers") + .HasColumnType("boolean"); + + b.Property("ImportOrders") + .HasColumnType("boolean"); + + b.Property("ImportProducts") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("URL") + .IsRequired() + .HasColumnType("text"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.Property("WarehouseId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WarehouseId"); + + b.ToTable("SalesChannel"); + }); + + modelBuilder.Entity("maERP.Server.Models.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Key") + .IsRequired() + .HasColumnType("text"); + + b.Property("Section") + .HasColumnType("integer"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Setting"); + + b.HasData( + new + { + Id = 1, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "JwtSettings:Key", + Section = 0, + Value = "CHANGE_TO_YOUR_VERY_SECRET_JWT_SIGNING_KEY" + }, + new + { + Id = 2, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "JwtSettings:Issuer", + Section = 0, + Value = "maERP.Server" + }, + new + { + Id = 3, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "JwtSettings:Audience", + Section = 0, + Value = "maERP.Client" + }, + new + { + Id = 4, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "JwtSettings:DurationInMinutes", + Section = 0, + Value = "60" + }, + new + { + Id = 5, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:Enabled", + Section = 0, + Value = "false" + }, + new + { + Id = 6, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:Host", + Section = 0, + Value = "graylog.martin-andrich.de" + }, + new + { + Id = 7, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:Port", + Section = 0, + Value = "12301" + }, + new + { + Id = 8, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:TransportType", + Section = 0, + Value = "Tcp" + }, + new + { + Id = 9, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:Facility", + Section = 0, + Value = "maERP.Server" + }); + }); + + modelBuilder.Entity("maERP.Server.Models.ShippingProvider", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ShippingProvider"); + }); + + modelBuilder.Entity("maERP.Server.Models.ShippingProviderRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("MaxHeight") + .HasColumnType("numeric"); + + b.Property("MaxLength") + .HasColumnType("numeric"); + + b.Property("MaxWeight") + .HasColumnType("numeric"); + + b.Property("MaxWidth") + .HasColumnType("numeric"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShippingProviderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ShippingProviderId"); + + b.ToTable("ShippingProviderRate"); + }); + + modelBuilder.Entity("maERP.Server.Models.TaxClass", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("TaxRate") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("TaxClass"); + }); + + modelBuilder.Entity("maERP.Server.Models.Warehouse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Warehouse"); + }); + + 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("maERP.Server.Models.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("maERP.Server.Models.ApplicationUser", 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("maERP.Server.Models.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("maERP.Server.Models.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("maERP.Server.Models.CustomerAddress", b => + { + b.HasOne("maERP.Server.Models.Country", "Country") + .WithMany() + .HasForeignKey("CountryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("maERP.Server.Models.Customer", "Customer") + .WithMany("CustomerAddresses") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Country"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("maERP.Server.Models.Order", b => + { + b.HasOne("maERP.Server.Models.Customer", null) + .WithMany("Orders") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("maERP.Server.Models.Product", b => + { + b.HasOne("maERP.Server.Models.TaxClass", "TaxClass") + .WithMany("Products") + .HasForeignKey("TaxClassId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TaxClass"); + }); + + modelBuilder.Entity("maERP.Server.Models.ProductSalesChannel", b => + { + b.HasOne("maERP.Server.Models.Product", "Product") + .WithMany("ProductSalesChannel") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("maERP.Server.Models.SalesChannel", "SalesChannel") + .WithMany() + .HasForeignKey("SalesChannelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("SalesChannel"); + }); + + modelBuilder.Entity("maERP.Server.Models.ProductStock", b => + { + b.HasOne("maERP.Server.Models.Product", "Product") + .WithMany("ProductStock") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("maERP.Server.Models.Warehouse", "Warehouse") + .WithMany() + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("maERP.Server.Models.SalesChannel", b => + { + b.HasOne("maERP.Server.Models.Warehouse", "Warehouse") + .WithMany("SalesChannels") + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("maERP.Server.Models.ShippingProviderRate", b => + { + b.HasOne("maERP.Server.Models.ShippingProvider", null) + .WithMany("ShippingRates") + .HasForeignKey("ShippingProviderId"); + }); + + modelBuilder.Entity("maERP.Server.Models.Customer", b => + { + b.Navigation("CustomerAddresses"); + + b.Navigation("Orders"); + }); + + modelBuilder.Entity("maERP.Server.Models.Product", b => + { + b.Navigation("ProductSalesChannel"); + + b.Navigation("ProductStock"); + }); + + modelBuilder.Entity("maERP.Server.Models.ShippingProvider", b => + { + b.Navigation("ShippingRates"); + }); + + modelBuilder.Entity("maERP.Server.Models.TaxClass", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("maERP.Server.Models.Warehouse", b => + { + b.Navigation("SalesChannels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/maERP.Server/Migrations/20230725194616_initDatabase.cs b/maERP.Server/Migrations/20230725194616_initDatabase.cs new file mode 100644 index 00000000..3c6d4c9f --- /dev/null +++ b/maERP.Server/Migrations/20230725194616_initDatabase.cs @@ -0,0 +1,661 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace maERP.Server.Migrations +{ + /// + public partial class initDatabase : 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: "text", nullable: false), + LastName = table.Column(type: "text", 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: "Country", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + CountryCode = table.Column(type: "text", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Country", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Customer", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + FirstName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + LastName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Email = table.Column(type: "text", nullable: false), + CustomerStatus = table.Column(type: "integer", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Customer", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Setting", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Section = table.Column(type: "integer", nullable: false), + Key = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Setting", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ShippingProvider", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShippingProvider", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TaxClass", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TaxRate = table.Column(type: "double precision", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TaxClass", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Warehouse", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Warehouse", 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.CreateTable( + name: "CustomerAddress", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Street = table.Column(type: "text", nullable: false), + HouseNr = table.Column(type: "text", nullable: false), + Zip = table.Column(type: "text", nullable: false), + City = table.Column(type: "text", nullable: false), + CountryId = table.Column(type: "integer", nullable: false), + CustomerId = table.Column(type: "integer", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CustomerAddress", x => x.Id); + table.ForeignKey( + name: "FK_CustomerAddress_Country_CountryId", + column: x => x.CountryId, + principalTable: "Country", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CustomerAddress_Customer_CustomerId", + column: x => x.CustomerId, + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Order", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CustomerId = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "integer", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Order", x => x.Id); + table.ForeignKey( + name: "FK_Order_Customer_CustomerId", + column: x => x.CustomerId, + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ShippingProviderRate", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + MaxLength = table.Column(type: "numeric", nullable: false), + MaxWidth = table.Column(type: "numeric", nullable: false), + MaxHeight = table.Column(type: "numeric", nullable: false), + MaxWeight = table.Column(type: "numeric", nullable: false), + ShippingProviderId = table.Column(type: "integer", nullable: true), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShippingProviderRate", x => x.Id); + table.ForeignKey( + name: "FK_ShippingProviderRate_ShippingProvider_ShippingProviderId", + column: x => x.ShippingProviderId, + principalTable: "ShippingProvider", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Product", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Sku = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Ean = table.Column(type: "text", nullable: false), + Asin = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + Price = table.Column(type: "numeric", nullable: false), + Msrp = table.Column(type: "numeric", nullable: false), + TaxClassId = table.Column(type: "integer", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Product", x => x.Id); + table.ForeignKey( + name: "FK_Product_TaxClass_TaxClassId", + column: x => x.TaxClassId, + principalTable: "TaxClass", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SalesChannel", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Type = table.Column(type: "integer", nullable: false), + Name = table.Column(type: "text", nullable: false), + URL = table.Column(type: "text", nullable: false), + Username = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false), + ImportProducts = table.Column(type: "boolean", nullable: false), + ImportCustomers = table.Column(type: "boolean", nullable: false), + ImportOrders = table.Column(type: "boolean", nullable: false), + ExportProducts = table.Column(type: "boolean", nullable: false), + ExportCustomers = table.Column(type: "boolean", nullable: false), + ExportOrders = table.Column(type: "boolean", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SalesChannel", x => x.Id); + table.ForeignKey( + name: "FK_SalesChannel_Warehouse_WarehouseId", + column: x => x.WarehouseId, + principalTable: "Warehouse", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProductStock", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ProductId = table.Column(type: "integer", nullable: false), + WarehouseId = table.Column(type: "integer", nullable: false), + Quantity = table.Column(type: "integer", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductStock", x => x.Id); + table.ForeignKey( + name: "FK_ProductStock_Product_ProductId", + column: x => x.ProductId, + principalTable: "Product", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductStock_Warehouse_WarehouseId", + column: x => x.WarehouseId, + principalTable: "Warehouse", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProductSalesChannel", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SalesChannelId = table.Column(type: "integer", nullable: false), + ProductId = table.Column(type: "integer", nullable: false), + RemoteProductId = table.Column(type: "integer", nullable: false), + Price = table.Column(type: "numeric", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductSalesChannel", x => x.Id); + table.ForeignKey( + name: "FK_ProductSalesChannel_Product_ProductId", + column: x => x.ProductId, + principalTable: "Product", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductSalesChannel_SalesChannel_SalesChannelId", + column: x => x.SalesChannelId, + principalTable: "SalesChannel", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "AspNetRoles", + columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, + values: new object[,] + { + { "02174cf0–9412–4cfe-afbf-59f706d72cf6", null, "Admin", "ADMIN" }, + { "341743f0-asd2–42de-afbf-59kmkkmk21ab1", null, "User", "USER" } + }); + + migrationBuilder.InsertData( + table: "AspNetUsers", + columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "FirstName", "LastName", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" }, + values: new object[] { "05474ea3–7543-8aef-bcae-33e812c35fc3", 0, "d04102f6-ba0d-45f3-acc5-a50a25709e4a", "admin@localhost.com", false, "Admin", "Admin", false, null, "ADMIN@LOCALHOST.COM", "ADMIN@LOCALHOST.COM", "AQAAAAIAAYagAAAAEO+hprJZuHzYVc2E/tGhDzQhzrGD4fS7i2htPWsCGyWMNu/I6YOd02aO1WAtEwRIQA==", null, false, "bbd2a186-408f-42a2-b6bd-6d427ee83176", false, "admin@localhost.com" }); + + migrationBuilder.InsertData( + table: "Country", + columns: new[] { "Id", "CountryCode", "DateCreated", "DateModified", "Name" }, + values: new object[,] + { + { 1, "de", new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), "Deutschland" }, + { 2, "at", new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), "Österreich" }, + { 3, "ch", new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), "Schweiz" } + }); + + migrationBuilder.InsertData( + table: "Setting", + columns: new[] { "Id", "DateCreated", "DateModified", "Key", "Section", "Value" }, + values: new object[,] + { + { 1, new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), "JwtSettings:Key", 0, "CHANGE_TO_YOUR_VERY_SECRET_JWT_SIGNING_KEY" }, + { 2, new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), "JwtSettings:Issuer", 0, "maERP.Server" }, + { 3, new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), "JwtSettings:Audience", 0, "maERP.Client" }, + { 4, new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), "JwtSettings:DurationInMinutes", 0, "60" }, + { 5, new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), "RemoteLog:Enabled", 0, "false" }, + { 6, new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), "RemoteLog:Host", 0, "graylog.martin-andrich.de" }, + { 7, new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), "RemoteLog:Port", 0, "12301" }, + { 8, new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), "RemoteLog:TransportType", 0, "Tcp" }, + { 9, new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), "RemoteLog:Facility", 0, "maERP.Server" } + }); + + migrationBuilder.InsertData( + table: "AspNetUserRoles", + columns: new[] { "RoleId", "UserId" }, + values: new object[] { "02174cf0–9412–4cfe-afbf-59f706d72cf6", "05474ea3–7543-8aef-bcae-33e812c35fc3" }); + + 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_CustomerAddress_CountryId", + table: "CustomerAddress", + column: "CountryId"); + + migrationBuilder.CreateIndex( + name: "IX_CustomerAddress_CustomerId", + table: "CustomerAddress", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_Order_CustomerId", + table: "Order", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_Product_Sku", + table: "Product", + column: "Sku", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Product_TaxClassId", + table: "Product", + column: "TaxClassId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductSalesChannel_ProductId", + table: "ProductSalesChannel", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductSalesChannel_SalesChannelId", + table: "ProductSalesChannel", + column: "SalesChannelId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductStock_ProductId", + table: "ProductStock", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductStock_WarehouseId", + table: "ProductStock", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_SalesChannel_WarehouseId", + table: "SalesChannel", + column: "WarehouseId"); + + migrationBuilder.CreateIndex( + name: "IX_ShippingProviderRate_ShippingProviderId", + table: "ShippingProviderRate", + column: "ShippingProviderId"); + } + + /// + 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: "CustomerAddress"); + + migrationBuilder.DropTable( + name: "Order"); + + migrationBuilder.DropTable( + name: "ProductSalesChannel"); + + migrationBuilder.DropTable( + name: "ProductStock"); + + migrationBuilder.DropTable( + name: "Setting"); + + migrationBuilder.DropTable( + name: "ShippingProviderRate"); + + migrationBuilder.DropTable( + name: "AspNetRoles"); + + migrationBuilder.DropTable( + name: "AspNetUsers"); + + migrationBuilder.DropTable( + name: "Country"); + + migrationBuilder.DropTable( + name: "Customer"); + + migrationBuilder.DropTable( + name: "SalesChannel"); + + migrationBuilder.DropTable( + name: "Product"); + + migrationBuilder.DropTable( + name: "ShippingProvider"); + + migrationBuilder.DropTable( + name: "Warehouse"); + + migrationBuilder.DropTable( + name: "TaxClass"); + } + } +} diff --git a/maERP.Server/Migrations/ApplicationDbContextModelSnapshot.cs b/maERP.Server/Migrations/ApplicationDbContextModelSnapshot.cs new file mode 100644 index 00000000..15906c66 --- /dev/null +++ b/maERP.Server/Migrations/ApplicationDbContextModelSnapshot.cs @@ -0,0 +1,1010 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using maERP.Server.Models; + +#nullable disable + +namespace maERP.Server.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + partial class ApplicationDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + 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 = "02174cf0–9412–4cfe-afbf-59f706d72cf6", + Name = "Admin", + NormalizedName = "ADMIN" + }, + new + { + Id = "341743f0-asd2–42de-afbf-59kmkkmk21ab1", + Name = "User", + NormalizedName = "USER" + }); + }); + + 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); + + b.HasData( + new + { + UserId = "05474ea3–7543-8aef-bcae-33e812c35fc3", + RoleId = "02174cf0–9412–4cfe-afbf-59f706d72cf6" + }); + }); + + 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("maERP.Server.Models.ApplicationUser", 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() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + 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); + + b.HasData( + new + { + Id = "05474ea3–7543-8aef-bcae-33e812c35fc3", + AccessFailedCount = 0, + ConcurrencyStamp = "d04102f6-ba0d-45f3-acc5-a50a25709e4a", + Email = "admin@localhost.com", + EmailConfirmed = false, + FirstName = "Admin", + LastName = "Admin", + LockoutEnabled = false, + NormalizedEmail = "ADMIN@LOCALHOST.COM", + NormalizedUserName = "ADMIN@LOCALHOST.COM", + PasswordHash = "AQAAAAIAAYagAAAAEO+hprJZuHzYVc2E/tGhDzQhzrGD4fS7i2htPWsCGyWMNu/I6YOd02aO1WAtEwRIQA==", + PhoneNumberConfirmed = false, + SecurityStamp = "bbd2a186-408f-42a2-b6bd-6d427ee83176", + TwoFactorEnabled = false, + UserName = "admin@localhost.com" + }); + }); + + modelBuilder.Entity("maERP.Server.Models.Country", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CountryCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Country"); + + b.HasData( + new + { + Id = 1, + CountryCode = "de", + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + Name = "Deutschland" + }, + new + { + Id = 2, + CountryCode = "at", + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + Name = "Österreich" + }, + new + { + Id = 3, + CountryCode = "ch", + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(10), + Name = "Schweiz" + }); + }); + + modelBuilder.Entity("maERP.Server.Models.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CustomerStatus") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.ToTable("Customer"); + }); + + modelBuilder.Entity("maERP.Server.Models.CustomerAddress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("City") + .IsRequired() + .HasColumnType("text"); + + b.Property("CountryId") + .HasColumnType("integer"); + + b.Property("CustomerId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("HouseNr") + .IsRequired() + .HasColumnType("text"); + + b.Property("Street") + .IsRequired() + .HasColumnType("text"); + + b.Property("Zip") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CountryId"); + + b.HasIndex("CustomerId"); + + b.ToTable("CustomerAddress"); + }); + + modelBuilder.Entity("maERP.Server.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CustomerId") + .HasColumnType("integer"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("maERP.Server.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Asin") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Ean") + .IsRequired() + .HasColumnType("text"); + + b.Property("Msrp") + .HasColumnType("numeric"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.Property("Sku") + .IsRequired() + .HasColumnType("text"); + + b.Property("TaxClassId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Sku") + .IsUnique(); + + b.HasIndex("TaxClassId"); + + b.ToTable("Product"); + }); + + modelBuilder.Entity("maERP.Server.Models.ProductSalesChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("RemoteProductId") + .HasColumnType("integer"); + + b.Property("SalesChannelId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("SalesChannelId"); + + b.ToTable("ProductSalesChannel"); + }); + + modelBuilder.Entity("maERP.Server.Models.ProductStock", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("ProductId") + .HasColumnType("integer"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.Property("WarehouseId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ProductId"); + + b.HasIndex("WarehouseId"); + + b.ToTable("ProductStock"); + }); + + modelBuilder.Entity("maERP.Server.Models.SalesChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("ExportCustomers") + .HasColumnType("boolean"); + + b.Property("ExportOrders") + .HasColumnType("boolean"); + + b.Property("ExportProducts") + .HasColumnType("boolean"); + + b.Property("ImportCustomers") + .HasColumnType("boolean"); + + b.Property("ImportOrders") + .HasColumnType("boolean"); + + b.Property("ImportProducts") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("URL") + .IsRequired() + .HasColumnType("text"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.Property("WarehouseId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("WarehouseId"); + + b.ToTable("SalesChannel"); + }); + + modelBuilder.Entity("maERP.Server.Models.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Key") + .IsRequired() + .HasColumnType("text"); + + b.Property("Section") + .HasColumnType("integer"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Setting"); + + b.HasData( + new + { + Id = 1, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "JwtSettings:Key", + Section = 0, + Value = "CHANGE_TO_YOUR_VERY_SECRET_JWT_SIGNING_KEY" + }, + new + { + Id = 2, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "JwtSettings:Issuer", + Section = 0, + Value = "maERP.Server" + }, + new + { + Id = 3, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "JwtSettings:Audience", + Section = 0, + Value = "maERP.Client" + }, + new + { + Id = 4, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "JwtSettings:DurationInMinutes", + Section = 0, + Value = "60" + }, + new + { + Id = 5, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:Enabled", + Section = 0, + Value = "false" + }, + new + { + Id = 6, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:Host", + Section = 0, + Value = "graylog.martin-andrich.de" + }, + new + { + Id = 7, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:Port", + Section = 0, + Value = "12301" + }, + new + { + Id = 8, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:TransportType", + Section = 0, + Value = "Tcp" + }, + new + { + Id = 9, + DateCreated = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + DateModified = new DateTime(2023, 7, 25, 19, 46, 16, 323, DateTimeKind.Utc).AddTicks(2930), + Key = "RemoteLog:Facility", + Section = 0, + Value = "maERP.Server" + }); + }); + + modelBuilder.Entity("maERP.Server.Models.ShippingProvider", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ShippingProvider"); + }); + + modelBuilder.Entity("maERP.Server.Models.ShippingProviderRate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("MaxHeight") + .HasColumnType("numeric"); + + b.Property("MaxLength") + .HasColumnType("numeric"); + + b.Property("MaxWeight") + .HasColumnType("numeric"); + + b.Property("MaxWidth") + .HasColumnType("numeric"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ShippingProviderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ShippingProviderId"); + + b.ToTable("ShippingProviderRate"); + }); + + modelBuilder.Entity("maERP.Server.Models.TaxClass", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("TaxRate") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("TaxClass"); + }); + + modelBuilder.Entity("maERP.Server.Models.Warehouse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Warehouse"); + }); + + 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("maERP.Server.Models.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("maERP.Server.Models.ApplicationUser", 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("maERP.Server.Models.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("maERP.Server.Models.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("maERP.Server.Models.CustomerAddress", b => + { + b.HasOne("maERP.Server.Models.Country", "Country") + .WithMany() + .HasForeignKey("CountryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("maERP.Server.Models.Customer", "Customer") + .WithMany("CustomerAddresses") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Country"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("maERP.Server.Models.Order", b => + { + b.HasOne("maERP.Server.Models.Customer", null) + .WithMany("Orders") + .HasForeignKey("CustomerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("maERP.Server.Models.Product", b => + { + b.HasOne("maERP.Server.Models.TaxClass", "TaxClass") + .WithMany("Products") + .HasForeignKey("TaxClassId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TaxClass"); + }); + + modelBuilder.Entity("maERP.Server.Models.ProductSalesChannel", b => + { + b.HasOne("maERP.Server.Models.Product", "Product") + .WithMany("ProductSalesChannel") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("maERP.Server.Models.SalesChannel", "SalesChannel") + .WithMany() + .HasForeignKey("SalesChannelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("SalesChannel"); + }); + + modelBuilder.Entity("maERP.Server.Models.ProductStock", b => + { + b.HasOne("maERP.Server.Models.Product", "Product") + .WithMany("ProductStock") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("maERP.Server.Models.Warehouse", "Warehouse") + .WithMany() + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("maERP.Server.Models.SalesChannel", b => + { + b.HasOne("maERP.Server.Models.Warehouse", "Warehouse") + .WithMany("SalesChannels") + .HasForeignKey("WarehouseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Warehouse"); + }); + + modelBuilder.Entity("maERP.Server.Models.ShippingProviderRate", b => + { + b.HasOne("maERP.Server.Models.ShippingProvider", null) + .WithMany("ShippingRates") + .HasForeignKey("ShippingProviderId"); + }); + + modelBuilder.Entity("maERP.Server.Models.Customer", b => + { + b.Navigation("CustomerAddresses"); + + b.Navigation("Orders"); + }); + + modelBuilder.Entity("maERP.Server.Models.Product", b => + { + b.Navigation("ProductSalesChannel"); + + b.Navigation("ProductStock"); + }); + + modelBuilder.Entity("maERP.Server.Models.ShippingProvider", b => + { + b.Navigation("ShippingRates"); + }); + + modelBuilder.Entity("maERP.Server.Models.TaxClass", b => + { + b.Navigation("Products"); + }); + + modelBuilder.Entity("maERP.Server.Models.Warehouse", b => + { + b.Navigation("SalesChannels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/maERP.Shared/Models/LoginFormModel.cs b/maERP.Shared/Models/LoginFormModel.cs index 70d051d6..1a3f9853 100644 --- a/maERP.Shared/Models/LoginFormModel.cs +++ b/maERP.Shared/Models/LoginFormModel.cs @@ -6,12 +6,19 @@ namespace maERP.Shared.Models; public class LoginFormModel { - public string? UserName { get; set; } = string.Empty; - public string? Password { get; set; } = string.Empty; - public List? ServerList { get; set; } + public string UserName { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public string Server { get; set; } = string.Empty; public bool RememberMe { get; set; } = false; } +public class LoginServer +{ + public string Url { get; set; } = string.Empty; + public string Version { get; set; } = string.Empty; + public DateTime LastUsed { get; set; } +} + public class LoginFormModelFluentValidator : AbstractValidator { private readonly IStringLocalizer _localizer; diff --git a/maERP.Shared/Pages/Auth/Login.razor b/maERP.Shared/Pages/Auth/Login.razor index 335100de..bb416c15 100644 --- a/maERP.Shared/Pages/Auth/Login.razor +++ b/maERP.Shared/Pages/Auth/Login.razor @@ -1,21 +1,15 @@ @page "/login" -@using maERP.Shared.Dtos.User -@using maERP.Shared.Models; - -@inject NavigationManager _navManager -@inject Blazored.LocalStorage.ILocalStorageService _localStorage -@inject maERP.Shared.Contracts.IAuthenticationService _authenticationService - -maERP +@**@ +maERP Login @* - - Kein Account? Jetzt registrieren - + + Kein Account? Jetzt registrieren + *@ + Class="mt-6"> - - - + InputType="InputType.Password" + Class="mt-6"> + + + @foreach (var server in _serverList) + { + @server.Url + } + + + +
- + Passwort vergessen
@@ -66,60 +64,30 @@
- -@code -{ - private string _title = "Login"; - - MudForm? _form; - bool _success; - bool _loading; - - List _server = new() - { - "https://localhost:8443" - }; - - LoginFormModel _model = new() - { - UserName = "admin@localhost.com", - Password = "maERP!12", - // Server = _server, - RememberMe = true - }; - - _model.ServerList = _server; - - // LoginDto loginDto = new LoginDto { Email = "admin@localhost.com", Password = "maERP!12", Server = "https://localhost:8443" }; - - private string _spinnerClass = string.Empty; - private string _errorMessage = string.Empty; - - protected override async Task OnInitializedAsync() - { - await base.OnInitializedAsync(); - _title = "Login"; - } - - private async void OnSubmit() - { - _spinnerClass = "spinner-border spinner-border-sm"; - - await _localStorage.SetItemAsStringAsync("server", _model.Server); - - var loginResponse = await _authenticationService.AuthenticateAsync(_model.UserName, _model.Password); - - if (loginResponse == true) - { - _navManager.NavigateTo("/"); - return; - } - - _errorMessage = "Login fehlgeschlagen"; - _spinnerClass = ""; - - await _localStorage.RemoveItemAsync("server"); - - this.StateHasChanged(); - } -} \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + Add + + + Schließen + + + \ No newline at end of file diff --git a/maERP.Shared/Pages/Auth/Login.razor.cs b/maERP.Shared/Pages/Auth/Login.razor.cs new file mode 100644 index 00000000..c82b3611 --- /dev/null +++ b/maERP.Shared/Pages/Auth/Login.razor.cs @@ -0,0 +1,130 @@ +using maERP.Shared.Models; +using Microsoft.AspNetCore.Components; +using MudBlazor; +using maERP.Shared.Contracts; +using Blazored.LocalStorage; +using System.Text.Json; + +namespace maERP.Shared.Pages.Auth; + +public partial class Login +{ + [Inject] + private NavigationManager? _navManager { get; set; } + + [Inject] + private ILocalStorageService? _localStorage { get; set; } + + [Inject] + private IAuthenticationService? _authenticationService { get; set; } + + private string _title = "Login"; + private bool _showServerOverlay; + private string newServer = string.Empty; + + MudForm? _form; + bool _success; + bool _loading; + + List _serverList = new(); + LoginFormModel _model = new(); + + private string _spinnerClass = string.Empty; + private string _errorMessage = string.Empty; + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + + if(await _localStorage.ContainKeyAsync("serverList")) + { + try + { + string serverJson = await _localStorage.GetItemAsStringAsync("serverList"); + _serverList = JsonSerializer.Deserialize>(serverJson); + } + catch + { + await _localStorage.RemoveItemAsync("serverList"); + } + } + + SelectFirstServerFromList(); + + if(await _localStorage.ContainKeyAsync("username")) + { + _model.UserName = await _localStorage.GetItemAsStringAsync("username"); + } + } + + public void OpenServerOverlay() + { + if (_showServerOverlay) + { + _showServerOverlay = false; + SelectFirstServerFromList(); + } + else + { + _showServerOverlay = true; + } + + StateHasChanged(); + } + + void RemoveFromServerList(string s) + { + _serverList = _serverList.Where(u => u.Url != s.ToString()).ToList(); + } + + void AddToServerList() + { + var newServerItem = new LoginServer + { + Url = newServer, + LastUsed = DateTime.MinValue, + Version = string.Empty + }; + + _serverList.Add(newServerItem); + newServer = string.Empty; + } + + void SelectFirstServerFromList() + { + if (_serverList.Count > 0) + { + _model.Server = _serverList.FirstOrDefault().Url; + } + } + + private async void OnSubmit() + { + _spinnerClass = "spinner-border spinner-border-sm"; + + await _localStorage.SetItemAsStringAsync("server", _model.Server); + + var loginResponse = await _authenticationService.AuthenticateAsync(_model.UserName, _model.Password); + + if (loginResponse == true) + { + if(_model.RememberMe == true) + { + await _localStorage.SetItemAsStringAsync("username", _model.UserName); + } + + string serverJson = JsonSerializer.Serialize(_serverList); + await _localStorage.SetItemAsStringAsync("serverList", serverJson); + + _navManager.NavigateTo("/"); + return; + } + + _errorMessage = "Login fehlgeschlagen"; + _spinnerClass = ""; + + await _localStorage.RemoveItemAsync("server"); + + this.StateHasChanged(); + } +} \ No newline at end of file diff --git a/maERP.Shared/Shared/MainLayout.razor b/maERP.Shared/Shared/MainLayout.razor index 426fb250..548a5b40 100644 --- a/maERP.Shared/Shared/MainLayout.razor +++ b/maERP.Shared/Shared/MainLayout.razor @@ -30,7 +30,6 @@
- @Body
diff --git a/maERP.Shared/maERP.Shared.csproj b/maERP.Shared/maERP.Shared.csproj index fb5477cc..fe21a12b 100644 --- a/maERP.Shared/maERP.Shared.csproj +++ b/maERP.Shared/maERP.Shared.csproj @@ -68,4 +68,8 @@ + + + + \ No newline at end of file diff --git a/maERP.Web/wwwroot/index.html b/maERP.Web/wwwroot/index.html index 3b10d542..00d0d8dd 100644 --- a/maERP.Web/wwwroot/index.html +++ b/maERP.Web/wwwroot/index.html @@ -8,7 +8,6 @@ -