From 85109c5dc176bfb70d282459dc40505656150cac Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 13 Apr 2023 00:10:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=91=D0=94=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81=20=D1=84=D1=80?= =?UTF-8?q?=D0=B5=D0=B9=D0=BC=D0=B2=D0=BE=D1=80=D0=BA=D0=BE=D0=BC.=20?= =?UTF-8?q?=D0=AD=D1=82=D0=BE=20=D1=82=D1=80=D0=B5=D1=88.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TransportCompany/TransportCompany.sln | 10 +- .../TransportCompany/TransportCompany.csproj | 19 ++ .../ElegevContext.cs | 150 +++++++++++ .../Implements/ClientStorage.cs | 47 ++++ .../20230412195202_StartMigration.Designer.cs | 239 ++++++++++++++++++ .../20230412195202_StartMigration.cs | 69 +++++ .../Migrations/ElegevContextModelSnapshot.cs | 236 +++++++++++++++++ .../Models/Cargo.cs | 13 + .../Models/Client.cs | 57 +++++ .../Models/Transport.cs | 13 + .../Models/Trucking.cs | 31 +++ .../Models/TypeTransportation.cs | 13 + .../TransportCompanyDatabaseImplements.csproj | 27 ++ 13 files changed, 922 insertions(+), 2 deletions(-) create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.Designer.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/ElegevContextModelSnapshot.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Models/TypeTransportation.cs create mode 100644 TransportCompany/TransportCompanyDatabaseImplements/TransportCompanyDatabaseImplements.csproj diff --git a/TransportCompany/TransportCompany.sln b/TransportCompany/TransportCompany.sln index 6ef24a9..209a19b 100644 --- a/TransportCompany/TransportCompany.sln +++ b/TransportCompany/TransportCompany.sln @@ -7,9 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompany", "Transpo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyDataModels", "TransportCompanyDataModels\TransportCompanyDataModels.csproj", "{C57B4449-A725-4804-833D-7CE33965F001}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompanyContracts", "TransportCompanyContracts\TransportCompanyContracts.csproj", "{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyContracts", "TransportCompanyContracts\TransportCompanyContracts.csproj", "{8707D719-D7B3-4F64-8BBE-DE9C7014DD13}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompanyBusinessLogic", "TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj", "{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyBusinessLogic", "TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj", "{5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompanyDatabaseImplements", "TransportCompanyDatabaseImplements\TransportCompanyDatabaseImplements.csproj", "{E421890B-5501-4A4D-931A-1B8139FDDB24}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,6 +35,10 @@ Global {5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Debug|Any CPU.Build.0 = Debug|Any CPU {5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Release|Any CPU.ActiveCfg = Release|Any CPU {5FD7F1C8-0B2C-4AD4-91FD-A4475274FD3A}.Release|Any CPU.Build.0 = Release|Any CPU + {E421890B-5501-4A4D-931A-1B8139FDDB24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E421890B-5501-4A4D-931A-1B8139FDDB24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E421890B-5501-4A4D-931A-1B8139FDDB24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E421890B-5501-4A4D-931A-1B8139FDDB24}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TransportCompany/TransportCompany/TransportCompany.csproj b/TransportCompany/TransportCompany/TransportCompany.csproj index b57c89e..a044fef 100644 --- a/TransportCompany/TransportCompany/TransportCompany.csproj +++ b/TransportCompany/TransportCompany/TransportCompany.csproj @@ -8,4 +8,23 @@ enable + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + \ No newline at end of file diff --git a/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs b/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs new file mode 100644 index 0000000..194baea --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; +using TransportCompanyDatabaseImplements.Models; + +namespace TransportCompanyDatabaseImplements; + +public partial class ElegevContext : DbContext +{ + public ElegevContext() + { + } + + public ElegevContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet Cargos { get; set; } + + public virtual DbSet Clients { get; set; } + + public virtual DbSet Transports { get; set; } + + public virtual DbSet Truckings { get; set; } + + public virtual DbSet TypeTransportations { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) +#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263. + => optionsBuilder.UseNpgsql("Host=192.168.56.101;Port=6000;Database=elegev;Username=elegev;Password=user"); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("cargo_pkey"); + + entity.ToTable("cargo"); + + entity.Property(e => e.Id) + .ValueGeneratedNever() + .HasColumnName("id"); + entity.Property(e => e.TypeCargo) + .HasMaxLength(255) + .HasColumnName("type_cargo"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("client_pkey"); + + entity.ToTable("client"); + + entity.Property(e => e.Id) + .ValueGeneratedNever() + .HasColumnName("id"); + entity.Property(e => e.Email) + .HasMaxLength(255) + .HasColumnName("email"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + entity.Property(e => e.Patronymic) + .HasMaxLength(255) + .HasColumnName("patronymic"); + entity.Property(e => e.Surname) + .HasMaxLength(255) + .HasColumnName("surname"); + entity.Property(e => e.Telephone) + .HasMaxLength(255) + .HasColumnName("telephone"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("transport_pkey"); + + entity.ToTable("transport"); + + entity.Property(e => e.Id) + .ValueGeneratedNever() + .HasColumnName("id"); + entity.Property(e => e.TransportType) + .HasMaxLength(255) + .HasColumnName("transport_type"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("trucking_pkey"); + + entity.ToTable("trucking"); + + entity.Property(e => e.Id) + .ValueGeneratedNever() + .HasColumnName("id"); + entity.Property(e => e.CargoId).HasColumnName("cargo_id"); + entity.Property(e => e.ClientId).HasColumnName("client_id"); + entity.Property(e => e.DateEnd).HasColumnName("date_end"); + entity.Property(e => e.DateStart).HasColumnName("date_start"); + entity.Property(e => e.Price).HasColumnName("price"); + entity.Property(e => e.TransportId).HasColumnName("transport_id"); + entity.Property(e => e.TypeTransportationId).HasColumnName("type_transportation_id"); + + entity.HasOne(d => d.Cargo).WithMany(p => p.Truckings) + .HasForeignKey(d => d.CargoId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("cargo_id"); + + entity.HasOne(d => d.Client).WithMany(p => p.Truckings) + .HasForeignKey(d => d.ClientId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("client_id"); + + entity.HasOne(d => d.Transport).WithMany(p => p.Truckings) + .HasForeignKey(d => d.TransportId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("transport_id"); + + entity.HasOne(d => d.TypeTransportation).WithMany(p => p.Truckings) + .HasForeignKey(d => d.TypeTransportationId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("type_transportation_id"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("type_transportation_pkey"); + + entity.ToTable("type_transportation"); + + entity.Property(e => e.Id) + .ValueGeneratedNever() + .HasColumnName("id"); + entity.Property(e => e.TransportationType) + .HasMaxLength(255) + .HasColumnName("transportation_type"); + }); + modelBuilder.HasSequence("seq_cargo"); + modelBuilder.HasSequence("seq_client"); + modelBuilder.HasSequence("seq_trucking"); + modelBuilder.HasSequence("seq_type_transport"); + modelBuilder.HasSequence("seq_type_transportation"); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs b/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs new file mode 100644 index 0000000..4b128f4 --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TransportCompanyContracts.BindingModels; +using TransportCompanyContracts.SearchModels; +using TransportCompanyContracts.StoragesContracts; +using TransportCompanyContracts.ViewModels; + +namespace TransportCompanyDatabaseImplements.Implements +{ + public class ClientStorage : IClientStorage + { + public List GetFullList() + { + using var context = new ElegevContext(); + + return context.Clients.ToList(); + } + + public List GetFilteredList(ClientSearchModel model) + { + throw new NotImplementedException(); + } + + public ClientViewModel? GetElement(ClientSearchModel model) + { + throw new NotImplementedException(); + } + + public ClientViewModel? Insert(ClientBindingModel model) + { + throw new NotImplementedException(); + } + + public ClientViewModel? Update(ClientBindingModel model) + { + throw new NotImplementedException(); + } + + public ClientViewModel? Delete(ClientBindingModel model) + { + throw new NotImplementedException(); + } + } +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.Designer.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.Designer.cs new file mode 100644 index 0000000..f527342 --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.Designer.cs @@ -0,0 +1,239 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using TransportCompanyDatabaseImplements; + +#nullable disable + +namespace TransportCompanyDatabaseImplements.Migrations +{ + [DbContext(typeof(ElegevContext))] + [Migration("20230412195202_StartMigration")] + partial class StartMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.HasSequence("seq_cargo"); + + modelBuilder.HasSequence("seq_client"); + + modelBuilder.HasSequence("seq_trucking"); + + modelBuilder.HasSequence("seq_type_transport"); + + modelBuilder.HasSequence("seq_type_transportation"); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Cargo", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("TypeCargo") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("type_cargo"); + + b.HasKey("Id") + .HasName("cargo_pkey"); + + b.ToTable("cargo", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Client", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("email"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("Patronymic") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("patronymic"); + + b.Property("Surname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("surname"); + + b.Property("Telephone") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("telephone"); + + b.HasKey("Id") + .HasName("client_pkey"); + + b.ToTable("client", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Transport", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("TransportType") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("transport_type"); + + b.HasKey("Id") + .HasName("transport_pkey"); + + b.ToTable("transport", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Trucking", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("CargoId") + .HasColumnType("integer") + .HasColumnName("cargo_id"); + + b.Property("ClientId") + .HasColumnType("integer") + .HasColumnName("client_id"); + + b.Property("DateEnd") + .HasColumnType("date") + .HasColumnName("date_end"); + + b.Property("DateStart") + .HasColumnType("date") + .HasColumnName("date_start"); + + b.Property("Price") + .HasColumnType("integer") + .HasColumnName("price"); + + b.Property("TransportId") + .HasColumnType("integer") + .HasColumnName("transport_id"); + + b.Property("TypeTransportationId") + .HasColumnType("integer") + .HasColumnName("type_transportation_id"); + + b.HasKey("Id") + .HasName("trucking_pkey"); + + b.HasIndex("CargoId"); + + b.HasIndex("ClientId"); + + b.HasIndex("TransportId"); + + b.HasIndex("TypeTransportationId"); + + b.ToTable("trucking", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.TypeTransportation", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("TransportationType") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("transportation_type"); + + b.HasKey("Id") + .HasName("type_transportation_pkey"); + + b.ToTable("type_transportation", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Trucking", b => + { + b.HasOne("TransportCompanyDatabaseImplements.Models.Cargo", "Cargo") + .WithMany("Truckings") + .HasForeignKey("CargoId") + .IsRequired() + .HasConstraintName("cargo_id"); + + b.HasOne("TransportCompanyDatabaseImplements.Models.Client", "Client") + .WithMany("Truckings") + .HasForeignKey("ClientId") + .IsRequired() + .HasConstraintName("client_id"); + + b.HasOne("TransportCompanyDatabaseImplements.Models.Transport", "Transport") + .WithMany("Truckings") + .HasForeignKey("TransportId") + .IsRequired() + .HasConstraintName("transport_id"); + + b.HasOne("TransportCompanyDatabaseImplements.Models.TypeTransportation", "TypeTransportation") + .WithMany("Truckings") + .HasForeignKey("TypeTransportationId") + .IsRequired() + .HasConstraintName("type_transportation_id"); + + b.Navigation("Cargo"); + + b.Navigation("Client"); + + b.Navigation("Transport"); + + b.Navigation("TypeTransportation"); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Cargo", b => + { + b.Navigation("Truckings"); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Client", b => + { + b.Navigation("Truckings"); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Transport", b => + { + b.Navigation("Truckings"); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.TypeTransportation", b => + { + b.Navigation("Truckings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.cs new file mode 100644 index 0000000..e9efd2d --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.cs @@ -0,0 +1,69 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TransportCompanyDatabaseImplements.Migrations +{ + /// + public partial class StartMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_trucking_cargo_id", + table: "trucking", + column: "cargo_id"); + + migrationBuilder.CreateIndex( + name: "IX_trucking_client_id", + table: "trucking", + column: "client_id"); + + migrationBuilder.CreateIndex( + name: "IX_trucking_transport_id", + table: "trucking", + column: "transport_id"); + + migrationBuilder.CreateIndex( + name: "IX_trucking_type_transportation_id", + table: "trucking", + column: "type_transportation_id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "trucking"); + + migrationBuilder.DropTable( + name: "cargo"); + + migrationBuilder.DropTable( + name: "client"); + + migrationBuilder.DropTable( + name: "transport"); + + migrationBuilder.DropTable( + name: "type_transportation"); + + migrationBuilder.DropSequence( + name: "seq_cargo"); + + migrationBuilder.DropSequence( + name: "seq_client"); + + migrationBuilder.DropSequence( + name: "seq_trucking"); + + migrationBuilder.DropSequence( + name: "seq_type_transport"); + + migrationBuilder.DropSequence( + name: "seq_type_transportation"); + } + } +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/ElegevContextModelSnapshot.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/ElegevContextModelSnapshot.cs new file mode 100644 index 0000000..b10b48a --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/ElegevContextModelSnapshot.cs @@ -0,0 +1,236 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using TransportCompanyDatabaseImplements; + +#nullable disable + +namespace TransportCompanyDatabaseImplements.Migrations +{ + [DbContext(typeof(ElegevContext))] + partial class ElegevContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.HasSequence("seq_cargo"); + + modelBuilder.HasSequence("seq_client"); + + modelBuilder.HasSequence("seq_trucking"); + + modelBuilder.HasSequence("seq_type_transport"); + + modelBuilder.HasSequence("seq_type_transportation"); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Cargo", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("TypeCargo") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("type_cargo"); + + b.HasKey("Id") + .HasName("cargo_pkey"); + + b.ToTable("cargo", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Client", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("email"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("Patronymic") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("patronymic"); + + b.Property("Surname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("surname"); + + b.Property("Telephone") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("telephone"); + + b.HasKey("Id") + .HasName("client_pkey"); + + b.ToTable("client", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Transport", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("TransportType") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("transport_type"); + + b.HasKey("Id") + .HasName("transport_pkey"); + + b.ToTable("transport", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Trucking", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("CargoId") + .HasColumnType("integer") + .HasColumnName("cargo_id"); + + b.Property("ClientId") + .HasColumnType("integer") + .HasColumnName("client_id"); + + b.Property("DateEnd") + .HasColumnType("date") + .HasColumnName("date_end"); + + b.Property("DateStart") + .HasColumnType("date") + .HasColumnName("date_start"); + + b.Property("Price") + .HasColumnType("integer") + .HasColumnName("price"); + + b.Property("TransportId") + .HasColumnType("integer") + .HasColumnName("transport_id"); + + b.Property("TypeTransportationId") + .HasColumnType("integer") + .HasColumnName("type_transportation_id"); + + b.HasKey("Id") + .HasName("trucking_pkey"); + + b.HasIndex("CargoId"); + + b.HasIndex("ClientId"); + + b.HasIndex("TransportId"); + + b.HasIndex("TypeTransportationId"); + + b.ToTable("trucking", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.TypeTransportation", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("TransportationType") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("transportation_type"); + + b.HasKey("Id") + .HasName("type_transportation_pkey"); + + b.ToTable("type_transportation", (string)null); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Trucking", b => + { + b.HasOne("TransportCompanyDatabaseImplements.Models.Cargo", "Cargo") + .WithMany("Truckings") + .HasForeignKey("CargoId") + .IsRequired() + .HasConstraintName("cargo_id"); + + b.HasOne("TransportCompanyDatabaseImplements.Models.Client", "Client") + .WithMany("Truckings") + .HasForeignKey("ClientId") + .IsRequired() + .HasConstraintName("client_id"); + + b.HasOne("TransportCompanyDatabaseImplements.Models.Transport", "Transport") + .WithMany("Truckings") + .HasForeignKey("TransportId") + .IsRequired() + .HasConstraintName("transport_id"); + + b.HasOne("TransportCompanyDatabaseImplements.Models.TypeTransportation", "TypeTransportation") + .WithMany("Truckings") + .HasForeignKey("TypeTransportationId") + .IsRequired() + .HasConstraintName("type_transportation_id"); + + b.Navigation("Cargo"); + + b.Navigation("Client"); + + b.Navigation("Transport"); + + b.Navigation("TypeTransportation"); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Cargo", b => + { + b.Navigation("Truckings"); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Client", b => + { + b.Navigation("Truckings"); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.Transport", b => + { + b.Navigation("Truckings"); + }); + + modelBuilder.Entity("TransportCompanyDatabaseImplements.Models.TypeTransportation", b => + { + b.Navigation("Truckings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs new file mode 100644 index 0000000..7d664c9 --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace TransportCompanyDatabaseImplements.Models; + +public partial class Cargo +{ + public int Id { get; set; } + + public string TypeCargo { get; set; } = null!; + + public virtual ICollection Truckings { get; set; } = new List(); +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs new file mode 100644 index 0000000..cc25807 --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using TransportCompanyContracts.BindingModels; +using TransportCompanyContracts.ViewModels; + +namespace TransportCompanyDatabaseImplements.Models; + +public partial class Client +{ + public int Id { get; set; } + + public string Name { get; set; } = null!; + + public string Surname { get; set; } = null!; + + public string Patronymic { get; set; } = null!; + + public string Telephone { get; set; } = null!; + + public string Email { get; set; } = null!; + + public virtual ICollection Truckings { get; set; } = new List(); + + public static Client Create(ElegevContext context, ClientBindingModel model) + { + return new Client() + { + Id = model.Id, + Name = model.Name, + Surname = model.Surname, + Patronymic = model.Patronymic, + Telephone = model.TelephoneNumber, + Email = model.Email, + }; + } + + public void Update(ClientBindingModel model) + { + Id = model.Id; + Name = model.Name; + Surname = model.Surname; + Patronymic = model.Patronymic; + Telephone = model.TelephoneNumber; + Email = model.Email; + } + + public ClientViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + Surname = Surname, + Patronymic = Patronymic, + TelephoneNumber = Telephone, + Email = Email + }; +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs new file mode 100644 index 0000000..9e19b3c --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace TransportCompanyDatabaseImplements.Models; + +public partial class Transport +{ + public int Id { get; set; } + + public string TransportType { get; set; } = null!; + + public virtual ICollection Truckings { get; set; } = new List(); +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs new file mode 100644 index 0000000..7ccbc6a --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace TransportCompanyDatabaseImplements.Models; + +public partial class Trucking +{ + public int Id { get; set; } + + public int ClientId { get; set; } + + public int CargoId { get; set; } + + public int Price { get; set; } + + public DateOnly DateStart { get; set; } + + public DateOnly DateEnd { get; set; } + + public int TypeTransportationId { get; set; } + + public int TransportId { get; set; } + + public virtual Cargo Cargo { get; set; } = null!; + + public virtual Client Client { get; set; } = null!; + + public virtual Transport Transport { get; set; } = null!; + + public virtual TypeTransportation TypeTransportation { get; set; } = null!; +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/TypeTransportation.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/TypeTransportation.cs new file mode 100644 index 0000000..adbbd9b --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/TypeTransportation.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace TransportCompanyDatabaseImplements.Models; + +public partial class TypeTransportation +{ + public int Id { get; set; } + + public string TransportationType { get; set; } = null!; + + public virtual ICollection Truckings { get; set; } = new List(); +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/TransportCompanyDatabaseImplements.csproj b/TransportCompany/TransportCompanyDatabaseImplements/TransportCompanyDatabaseImplements.csproj new file mode 100644 index 0000000..07207df --- /dev/null +++ b/TransportCompany/TransportCompanyDatabaseImplements/TransportCompanyDatabaseImplements.csproj @@ -0,0 +1,27 @@ + + + + net6.0 + enable + enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + +