From bf77b92a4b9f8003d3894dc5ee4f438297fd9b58 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 13 Apr 2023 15:32:45 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B0=D0=BD=D0=BD=D0=B0=D1=8F=204-?= =?UTF-8?q?=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=B0.=20=D0=9F=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=D1=82=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB?= =?UTF-8?q?=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=84=D0=B8=D0=B3=20+=20=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=BE=D1=82=D1=87=D1=91=D1=82=D1=8B=20?= =?UTF-8?q?=D0=BA=205-=D0=B9=20=D0=BB=D0=B0=D0=B1=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TransportCompany/FormTrucking.Designer.cs | 42 ++- .../TransportCompany/FormTrucking.cs | 28 +- .../TransportCompany/SortableBindingList.cs | 103 ++++++++ .../ElegevContext.cs | 18 +- .../Implements/TruckingStorage.cs | 12 +- .../20230412195202_StartMigration.Designer.cs | 239 ------------------ .../20230412195202_StartMigration.cs | 69 ----- .../20230412213501_FirstMigra.Designer.cs | 239 ------------------ .../Migrations/20230412213501_FirstMigra.cs | 87 ------- .../20230413092204_ClearClients.Designer.cs | 239 ------------------ .../Migrations/20230413092204_ClearClients.cs | 22 -- .../Migrations/ElegevContextModelSnapshot.cs | 236 ----------------- .../Models/Cargo.cs | 2 - .../Models/Client.cs | 4 +- .../Models/Transport.cs | 1 - .../Models/Trucking.cs | 17 +- 16 files changed, 202 insertions(+), 1156 deletions(-) create mode 100644 TransportCompany/TransportCompany/SortableBindingList.cs delete mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.Designer.cs delete mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.cs delete mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412213501_FirstMigra.Designer.cs delete mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412213501_FirstMigra.cs delete mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.Designer.cs delete mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.cs delete mode 100644 TransportCompany/TransportCompanyDatabaseImplements/Migrations/ElegevContextModelSnapshot.cs diff --git a/TransportCompany/TransportCompany/FormTrucking.Designer.cs b/TransportCompany/TransportCompany/FormTrucking.Designer.cs index cab8ba1..d20eed7 100644 --- a/TransportCompany/TransportCompany/FormTrucking.Designer.cs +++ b/TransportCompany/TransportCompany/FormTrucking.Designer.cs @@ -40,6 +40,9 @@ generationClientsToolStripMenuItem = new ToolStripMenuItem(); generationTruckingsToolStripMenuItem = new ToolStripMenuItem(); buttonUpdate = new Button(); + comboBoxEmails = new ComboBox(); + label1 = new Label(); + checkBoxSorted = new CheckBox(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); menuStrip.SuspendLayout(); SuspendLayout(); @@ -47,11 +50,11 @@ // dataGridView // dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(11, 36); + dataGridView.Location = new Point(11, 67); dataGridView.Name = "dataGridView"; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(937, 448); + dataGridView.Size = new Size(937, 417); dataGridView.TabIndex = 0; // // buttonCreateTrucking @@ -141,11 +144,43 @@ buttonUpdate.UseVisualStyleBackColor = true; buttonUpdate.Click += ButtonUpdate_Click; // + // comboBoxEmails + // + comboBoxEmails.FormattingEnabled = true; + comboBoxEmails.Location = new Point(142, 33); + comboBoxEmails.Name = "comboBoxEmails"; + comboBoxEmails.Size = new Size(208, 28); + comboBoxEmails.TabIndex = 8; + comboBoxEmails.SelectedIndexChanged += ComboBoxEmails_SelectedIndexChanged; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 36); + label1.Name = "label1"; + label1.Size = new Size(124, 20); + label1.TabIndex = 9; + label1.Text = "Выберите почту:"; + // + // checkBoxSorted + // + checkBoxSorted.AutoSize = true; + checkBoxSorted.Location = new Point(541, 35); + checkBoxSorted.Name = "checkBoxSorted"; + checkBoxSorted.Size = new Size(239, 24); + checkBoxSorted.TabIndex = 10; + checkBoxSorted.Text = "Сортировать по возрастанию"; + checkBoxSorted.UseVisualStyleBackColor = true; + checkBoxSorted.CheckedChanged += CheckBoxSorted_CheckedChanged; + // // FormTrucking // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(1297, 496); + Controls.Add(checkBoxSorted); + Controls.Add(label1); + Controls.Add(comboBoxEmails); Controls.Add(buttonUpdate); Controls.Add(buttonCreateTrucking); Controls.Add(dataGridView); @@ -188,5 +223,8 @@ private ToolStripMenuItem generationClientsToolStripMenuItem; private ToolStripMenuItem generationTruckingsToolStripMenuItem; private Button buttonUpdate; + private ComboBox comboBoxEmails; + private Label label1; + private CheckBox checkBoxSorted; } } \ No newline at end of file diff --git a/TransportCompany/TransportCompany/FormTrucking.cs b/TransportCompany/TransportCompany/FormTrucking.cs index 5bffa4f..5b33aae 100644 --- a/TransportCompany/TransportCompany/FormTrucking.cs +++ b/TransportCompany/TransportCompany/FormTrucking.cs @@ -1,5 +1,8 @@ using Microsoft.Extensions.Logging; +using System.ComponentModel; +using System.Windows.Forms; using TransportCompanyContracts.BusinessLogicsContracts; +using TransportCompanyContracts.SearchModels; namespace TransportCompany { @@ -9,12 +12,15 @@ namespace TransportCompany private readonly ITruckingLogic _truckingLogic; - public FormTrucking(ILogger logger, ITruckingLogic truckingLogic) + private readonly IClientLogic _clientLogic; + + public FormTrucking(ILogger logger, ITruckingLogic truckingLogic, IClientLogic clientLogic) { InitializeComponent(); _logger = logger; _truckingLogic = truckingLogic; + _clientLogic = clientLogic; } private void FormMain_Load(object sender, EventArgs e) @@ -30,6 +36,8 @@ namespace TransportCompany { var list = _truckingLogic.ReadList(null); + var listClients = _clientLogic.ReadList(null); + if (list != null) { dataGridView.DataSource = list; @@ -39,6 +47,14 @@ namespace TransportCompany dataGridView.Columns["TransportationId"].Visible = false; } + if (listClients != null) + { + comboBoxEmails.DisplayMember = "Email"; + comboBoxEmails.ValueMember = "Id"; + comboBoxEmails.DataSource = listClients; + comboBoxEmails.SelectedItem = null; + } + _logger.LogInformation(" "); } catch (Exception ex) @@ -129,5 +145,15 @@ namespace TransportCompany { LoadData(); } + + private void ComboBoxEmails_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void CheckBoxSorted_CheckedChanged(object sender, EventArgs e) + { + //dataGridView. Sort(dataGridView.Columns[7], ListSortDirection.Ascending); + } } } \ No newline at end of file diff --git a/TransportCompany/TransportCompany/SortableBindingList.cs b/TransportCompany/TransportCompany/SortableBindingList.cs new file mode 100644 index 0000000..30ae163 --- /dev/null +++ b/TransportCompany/TransportCompany/SortableBindingList.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace TransportCompany +{ + public class SortableBindingList : BindingList + { + private bool IsSorted { get; set; } + + private ListSortDirection SortDirection { get; set; } + + private PropertyDescriptor SortProperty { get; set; } + + protected override bool SupportsSortingCore + { + get + { + return true; + } + } + + protected override ListSortDirection SortDirectionCore + { + get + { + return SortDirection; + } + } + + protected override PropertyDescriptor SortPropertyCore + { + get + { + return SortProperty; + } + } + + protected override void ApplySortCore(PropertyDescriptor PDsc, ListSortDirection Direction) + { + List items = Items as List; + if (items is null) + { + IsSorted = false; + } + else + { + var PCom = new PCompare(PDsc.Name, Direction); + items.Sort(PCom); + IsSorted = true; + SortDirection = Direction; + SortProperty = PDsc; + } + OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1)); + } + + protected override bool IsSortedCore + { + get + { + return IsSorted; + } + } + + protected override void RemoveSortCore() + { + IsSorted = false; + } + + #region Constructors + public SortableBindingList(ICollection list) : base((IList)list) + { + } + public SortableBindingList() : base() + { + } + + #endregion + #region Property comparer + private class PCompare : IComparer + { + private PropertyInfo PropInfo { get; set; } + private ListSortDirection SortDir { get; set; } + internal PCompare(string SortProperty, ListSortDirection SortDirection) + { + PropInfo = typeof(T).GetProperty(SortProperty); + SortDir = SortDirection; + } + internal int Compare(T x, T y) + { + return SortDir == ListSortDirection.Ascending ? Comparer.Default.Compare(PropInfo.GetValue(x, null), PropInfo.GetValue(y, null)) : Comparer.Default.Compare(PropInfo.GetValue(y, null), PropInfo.GetValue(x, null)); + } + + int IComparer.Compare(T x, T y) => Compare(x, y); + } + #endregion + } +} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs b/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs index 9322118..ec57a2c 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs @@ -92,13 +92,25 @@ public partial class ElegevContext : DbContext entity.ToTable("trucking"); + entity.HasIndex(e => e.CargoId, "IX_trucking_cargo_id"); + + entity.HasIndex(e => e.ClientId, "IX_trucking_client_id"); + + entity.HasIndex(e => e.TransportId, "IX_trucking_transport_id"); + + entity.HasIndex(e => e.TransportationId, "IX_trucking_transportation_id"); + 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.DateEnd) + .HasColumnType("timestamp without time zone") + .HasColumnName("date_end"); + entity.Property(e => e.DateStart) + .HasColumnType("timestamp without time zone") + .HasColumnName("date_start"); entity.Property(e => e.Price).HasColumnName("price"); entity.Property(e => e.TransportId).HasColumnName("transport_id"); entity.Property(e => e.TransportationId).HasColumnName("transportation_id"); @@ -118,7 +130,7 @@ public partial class ElegevContext : DbContext .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("transport_id"); - entity.HasOne(d => d.TypeTransportation).WithMany(p => p.Truckings) + entity.HasOne(d => d.Transportation).WithMany(p => p.Truckings) .HasForeignKey(d => d.TransportationId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("type_transportation_id"); diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs index 17e288d..1cb4303 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs @@ -66,6 +66,10 @@ namespace TransportCompanyDatabaseImplements.Implements using var context = new ElegevContext(); return context.Truckings + .Include(x => x.Transport) + .Include(x => x.Cargo) + .Include(x => x.Transportation) + .Include(x => x.Client) .Select(x => x.GetViewModel) .ToList(); } @@ -89,10 +93,10 @@ namespace TransportCompanyDatabaseImplements.Implements return context.Truckings .Include(x => x.Transport) .Include(x => x.Cargo) - .Include(x => x.TypeTransportation) - .Include (x => x.Client) - .Select(x => x.GetViewModel) - .FirstOrDefault(x => x.Id == model.Id); + .Include(x => x.Transportation) + .Include(x => x.Client) + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; } public TruckingViewModel? Update(TruckingBindingModel model) diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.Designer.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.Designer.cs deleted file mode 100644 index f527342..0000000 --- a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.Designer.cs +++ /dev/null @@ -1,239 +0,0 @@ -// -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 deleted file mode 100644 index e9efd2d..0000000 --- a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412195202_StartMigration.cs +++ /dev/null @@ -1,69 +0,0 @@ -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/20230412213501_FirstMigra.Designer.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412213501_FirstMigra.Designer.cs deleted file mode 100644 index ae09b0d..0000000 --- a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412213501_FirstMigra.Designer.cs +++ /dev/null @@ -1,239 +0,0 @@ -// -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("20230412213501_FirstMigra")] - partial class FirstMigra - { - /// - 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("timestamp with time zone") - .HasColumnName("date_end"); - - b.Property("DateStart") - .HasColumnType("timestamp with time zone") - .HasColumnName("date_start"); - - b.Property("Price") - .HasColumnType("double precision") - .HasColumnName("price"); - - b.Property("TransportId") - .HasColumnType("integer") - .HasColumnName("transport_id"); - - b.Property("TransportationId") - .HasColumnType("integer") - .HasColumnName("transportation_id"); - - b.HasKey("Id") - .HasName("trucking_pkey"); - - b.HasIndex("CargoId"); - - b.HasIndex("ClientId"); - - b.HasIndex("TransportId"); - - b.HasIndex("TransportationId"); - - 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("TransportationId") - .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/20230412213501_FirstMigra.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412213501_FirstMigra.cs deleted file mode 100644 index 902e467..0000000 --- a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230412213501_FirstMigra.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace TransportCompanyDatabaseImplements.Migrations -{ - /// - public partial class FirstMigra : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "type_transportation_id", - table: "trucking", - newName: "transportation_id"); - - migrationBuilder.RenameIndex( - name: "IX_trucking_type_transportation_id", - table: "trucking", - newName: "IX_trucking_transportation_id"); - - migrationBuilder.AlterColumn( - name: "price", - table: "trucking", - type: "double precision", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AlterColumn( - name: "date_start", - table: "trucking", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateOnly), - oldType: "date"); - - migrationBuilder.AlterColumn( - name: "date_end", - table: "trucking", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateOnly), - oldType: "date"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "transportation_id", - table: "trucking", - newName: "type_transportation_id"); - - migrationBuilder.RenameIndex( - name: "IX_trucking_transportation_id", - table: "trucking", - newName: "IX_trucking_type_transportation_id"); - - migrationBuilder.AlterColumn( - name: "price", - table: "trucking", - type: "integer", - nullable: false, - oldClrType: typeof(double), - oldType: "double precision"); - - migrationBuilder.AlterColumn( - name: "date_start", - table: "trucking", - type: "date", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - - migrationBuilder.AlterColumn( - name: "date_end", - table: "trucking", - type: "date", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - } - } -} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.Designer.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.Designer.cs deleted file mode 100644 index d435610..0000000 --- a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.Designer.cs +++ /dev/null @@ -1,239 +0,0 @@ -// -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("20230413092204_ClearClients")] - partial class ClearClients - { - /// - 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("timestamp with time zone") - .HasColumnName("date_end"); - - b.Property("DateStart") - .HasColumnType("timestamp with time zone") - .HasColumnName("date_start"); - - b.Property("Price") - .HasColumnType("double precision") - .HasColumnName("price"); - - b.Property("TransportId") - .HasColumnType("integer") - .HasColumnName("transport_id"); - - b.Property("TransportationId") - .HasColumnType("integer") - .HasColumnName("transportation_id"); - - b.HasKey("Id") - .HasName("trucking_pkey"); - - b.HasIndex("CargoId"); - - b.HasIndex("ClientId"); - - b.HasIndex("TransportId"); - - b.HasIndex("TransportationId"); - - 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("TransportationId") - .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/20230413092204_ClearClients.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.cs deleted file mode 100644 index d5f1616..0000000 --- a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/20230413092204_ClearClients.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace TransportCompanyDatabaseImplements.Migrations -{ - /// - public partial class ClearClients : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/ElegevContextModelSnapshot.cs b/TransportCompany/TransportCompanyDatabaseImplements/Migrations/ElegevContextModelSnapshot.cs deleted file mode 100644 index 65069f1..0000000 --- a/TransportCompany/TransportCompanyDatabaseImplements/Migrations/ElegevContextModelSnapshot.cs +++ /dev/null @@ -1,236 +0,0 @@ -// -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("timestamp with time zone") - .HasColumnName("date_end"); - - b.Property("DateStart") - .HasColumnType("timestamp with time zone") - .HasColumnName("date_start"); - - b.Property("Price") - .HasColumnType("double precision") - .HasColumnName("price"); - - b.Property("TransportId") - .HasColumnType("integer") - .HasColumnName("transport_id"); - - b.Property("TransportationId") - .HasColumnType("integer") - .HasColumnName("transportation_id"); - - b.HasKey("Id") - .HasName("trucking_pkey"); - - b.HasIndex("CargoId"); - - b.HasIndex("ClientId"); - - b.HasIndex("TransportId"); - - b.HasIndex("TransportationId"); - - 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("TransportationId") - .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 index 0839209..b952d16 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using TransportCompanyContracts.BindingModels; using TransportCompanyContracts.ViewModels; @@ -33,5 +32,4 @@ public partial class Cargo Id = Id, TypeCargo = TypeCargo }; - } diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs index 66b1fc0..ba939b6 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs @@ -1,13 +1,11 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using TransportCompanyContracts.BindingModels; using TransportCompanyContracts.ViewModels; -using TransportCompanyDataModels.Models; namespace TransportCompanyDatabaseImplements.Models; -public partial class Client : IClientModel +public partial class Client { public int Id { get; set; } diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs index f81af42..a8339df 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Xml.Linq; using TransportCompanyContracts.BindingModels; using TransportCompanyContracts.ViewModels; diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs index 34fa2a9..dad1135 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs @@ -2,11 +2,10 @@ using System.Collections.Generic; using TransportCompanyContracts.BindingModels; using TransportCompanyContracts.ViewModels; -using TransportCompanyDataModels.Models; namespace TransportCompanyDatabaseImplements.Models; -public partial class Trucking : ITruckingModel +public partial class Trucking { public int Id { get; set; } @@ -30,7 +29,7 @@ public partial class Trucking : ITruckingModel public virtual Transport Transport { get; set; } = null!; - public virtual TypeTransportation TypeTransportation { get; set; } = null!; + public virtual TypeTransportation Transportation { get; set; } = null!; public static Trucking? Create(TruckingBindingModel model) { @@ -79,11 +78,11 @@ public partial class Trucking : ITruckingModel DateEnd = DateEnd, TransportationId = TransportationId, TransportId = TransportId, - ClientName = Client.Name, - ClientSurname = Client.Surname, - ClientPatronymic = Client.Patronymic, - TypeTransportation = TypeTransportation.TransportationType, - TransportName = Transport.TransportType, - Cargo = Cargo.TypeCargo + ClientName = Client == null ? string.Empty : Client.Name, + ClientSurname = Client == null ? string.Empty : Client.Surname, + ClientPatronymic = Client == null ? string.Empty : Client.Patronymic, + TypeTransportation = Transportation == null ? string.Empty : Transportation.TransportationType, + TransportName = Transport == null ? string.Empty : Transport.TransportType, + Cargo = Cargo == null ? string.Empty : Cargo.TypeCargo }; }