From e05d5c950bd376573e4b9bdf5b22416f2f6e9d1f Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 13 Apr 2023 00:49:02 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B5=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/ClientBindingModel.cs | 2 +- .../ViewModels/ClientViewModel.cs | 2 +- .../Models/IClientModel.cs | 2 +- .../Models/Cargo.cs | 24 +++++++ .../Models/Client.cs | 11 +-- .../Models/Transport.cs | 24 +++++++ .../Models/Trucking.cs | 68 +++++++++++++++++-- .../Models/TypeTransportation.cs | 23 +++++++ 8 files changed, 143 insertions(+), 13 deletions(-) diff --git a/TransportCompany/TransportCompanyContracts/BindingModels/ClientBindingModel.cs b/TransportCompany/TransportCompanyContracts/BindingModels/ClientBindingModel.cs index 71a8b1e..d26a6c6 100644 --- a/TransportCompany/TransportCompanyContracts/BindingModels/ClientBindingModel.cs +++ b/TransportCompany/TransportCompanyContracts/BindingModels/ClientBindingModel.cs @@ -17,7 +17,7 @@ namespace TransportCompanyContracts.BindingModels public string Patronymic { get; set; } = string.Empty; - public string TelephoneNumber { get; set; } = string.Empty; + public string Telephone { get; set; } = string.Empty; public string Email { get; set; } = string.Empty; } diff --git a/TransportCompany/TransportCompanyContracts/ViewModels/ClientViewModel.cs b/TransportCompany/TransportCompanyContracts/ViewModels/ClientViewModel.cs index 53efa1a..9ed4f06 100644 --- a/TransportCompany/TransportCompanyContracts/ViewModels/ClientViewModel.cs +++ b/TransportCompany/TransportCompanyContracts/ViewModels/ClientViewModel.cs @@ -22,7 +22,7 @@ namespace TransportCompanyContracts.ViewModels public string Patronymic { get; set; } = string.Empty; [DisplayName("Телефон")] - public string TelephoneNumber { get; set; } = string.Empty; + public string Telephone { get; set; } = string.Empty; [DisplayName("Почта")] public string Email { get; set; } = string.Empty; diff --git a/TransportCompany/TransportCompanyDataModels/Models/IClientModel.cs b/TransportCompany/TransportCompanyDataModels/Models/IClientModel.cs index 2c238f8..9e93af8 100644 --- a/TransportCompany/TransportCompanyDataModels/Models/IClientModel.cs +++ b/TransportCompany/TransportCompanyDataModels/Models/IClientModel.cs @@ -15,7 +15,7 @@ namespace TransportCompanyDataModels.Models //отчество string Patronymic { get; } - string TelephoneNumber { get; } + string Telephone { get; } string Email { get; } } diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs index 7d664c9..0839209 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Cargo.cs @@ -1,5 +1,8 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using TransportCompanyContracts.BindingModels; +using TransportCompanyContracts.ViewModels; namespace TransportCompanyDatabaseImplements.Models; @@ -10,4 +13,25 @@ public partial class Cargo public string TypeCargo { get; set; } = null!; public virtual ICollection Truckings { get; set; } = new List(); + + public static Cargo Create(CargoBindingModel model) + { + return new Cargo() + { + Id = model.Id, + TypeCargo = model.TypeCargo + }; + } + + public void Update(CargoBindingModel model) + { + TypeCargo = model.TypeCargo; + } + + public CargoViewModel GetViewModel => new() + { + Id = Id, + TypeCargo = TypeCargo + }; + } diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs index cc25807..66b1fc0 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Client.cs @@ -3,10 +3,11 @@ using System.Collections.Generic; using System.Diagnostics; using TransportCompanyContracts.BindingModels; using TransportCompanyContracts.ViewModels; +using TransportCompanyDataModels.Models; namespace TransportCompanyDatabaseImplements.Models; -public partial class Client +public partial class Client : IClientModel { public int Id { get; set; } @@ -22,7 +23,7 @@ public partial class Client public virtual ICollection Truckings { get; set; } = new List(); - public static Client Create(ElegevContext context, ClientBindingModel model) + public static Client Create(ClientBindingModel model) { return new Client() { @@ -30,7 +31,7 @@ public partial class Client Name = model.Name, Surname = model.Surname, Patronymic = model.Patronymic, - Telephone = model.TelephoneNumber, + Telephone = model.Telephone, Email = model.Email, }; } @@ -41,7 +42,7 @@ public partial class Client Name = model.Name; Surname = model.Surname; Patronymic = model.Patronymic; - Telephone = model.TelephoneNumber; + Telephone = model.Telephone; Email = model.Email; } @@ -51,7 +52,7 @@ public partial class Client Name = Name, Surname = Surname, Patronymic = Patronymic, - TelephoneNumber = Telephone, + Telephone = Telephone, Email = Email }; } diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs index 9e19b3c..f81af42 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Transport.cs @@ -1,5 +1,8 @@ using System; using System.Collections.Generic; +using System.Xml.Linq; +using TransportCompanyContracts.BindingModels; +using TransportCompanyContracts.ViewModels; namespace TransportCompanyDatabaseImplements.Models; @@ -10,4 +13,25 @@ public partial class Transport public string TransportType { get; set; } = null!; public virtual ICollection Truckings { get; set; } = new List(); + + public static Transport Create(TransportBindingModel model) + { + return new Transport() + { + Id = model.Id, + TransportType = model.Tranport + }; + } + + public void Update(TransportBindingModel model) + { + Id = model.Id; + TransportType = model.Tranport; + } + + public TransportViewModel GetViewModel => new() + { + Id = Id, + Tranport = TransportType + }; } diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs index 7ccbc6a..34fa2a9 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/Trucking.cs @@ -1,9 +1,12 @@ using System; using System.Collections.Generic; +using TransportCompanyContracts.BindingModels; +using TransportCompanyContracts.ViewModels; +using TransportCompanyDataModels.Models; namespace TransportCompanyDatabaseImplements.Models; -public partial class Trucking +public partial class Trucking : ITruckingModel { public int Id { get; set; } @@ -11,13 +14,13 @@ public partial class Trucking public int CargoId { get; set; } - public int Price { get; set; } + public double Price { get; set; } - public DateOnly DateStart { get; set; } + public DateTime DateStart { get; set; } - public DateOnly DateEnd { get; set; } + public DateTime DateEnd { get; set; } - public int TypeTransportationId { get; set; } + public int TransportationId { get; set; } public int TransportId { get; set; } @@ -28,4 +31,59 @@ public partial class Trucking public virtual Transport Transport { get; set; } = null!; public virtual TypeTransportation TypeTransportation { get; set; } = null!; + + public static Trucking? Create(TruckingBindingModel model) + { + if (model == null) + { + return null; + } + + return new Trucking() + { + Id = model.Id, + ClientId = model.ClientId, + CargoId = model.CargoId, + Price = model.Price, + DateStart = model.DateStart, + DateEnd = model.DateEnd, + TransportationId = model.TransportationId, + TransportId = model.TransportId + }; + } + + public void Update(TruckingBindingModel model) + { + if (model == null) + { + return; + } + + Id = model.Id; + ClientId = model.ClientId; + CargoId = model.CargoId; + Price = model.Price; + DateStart = model.DateStart; + DateEnd = model.DateEnd; + TransportationId = model.TransportationId; + TransportId = model.TransportId; + } + + public TruckingViewModel GetViewModel => new() + { + Id = Id, + ClientId = ClientId, + CargoId = CargoId, + Price = Price, + DateStart = DateStart, + DateEnd = DateEnd, + TransportationId = TransportationId, + TransportId = TransportId, + ClientName = Client.Name, + ClientSurname = Client.Surname, + ClientPatronymic = Client.Patronymic, + TypeTransportation = TypeTransportation.TransportationType, + TransportName = Transport.TransportType, + Cargo = Cargo.TypeCargo + }; } diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Models/TypeTransportation.cs b/TransportCompany/TransportCompanyDatabaseImplements/Models/TypeTransportation.cs index adbbd9b..b5cb431 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/Models/TypeTransportation.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/Models/TypeTransportation.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using TransportCompanyContracts.BindingModels; +using TransportCompanyContracts.ViewModels; namespace TransportCompanyDatabaseImplements.Models; @@ -10,4 +12,25 @@ public partial class TypeTransportation public string TransportationType { get; set; } = null!; public virtual ICollection Truckings { get; set; } = new List(); + + public static TypeTransportation Create(TransportationBindingModel model) + { + return new TypeTransportation() + { + Id = model.Id, + TransportationType = model.TransportationType + }; + } + + public void Update(TransportationBindingModel model) + { + Id = model.Id; + TransportationType = model.TransportationType; + } + + public TransportationViewModel GetViewModel => new() + { + Id = Id, + TransportationType = TransportationType + }; }