Проработка моделей сущностей.

This commit is contained in:
Programmist73 2023-04-13 00:49:02 +04:00
parent 85109c5dc1
commit e05d5c950b
8 changed files with 143 additions and 13 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -15,7 +15,7 @@ namespace TransportCompanyDataModels.Models
//отчество
string Patronymic { get; }
string TelephoneNumber { get; }
string Telephone { get; }
string Email { get; }
}

View File

@ -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<Trucking> Truckings { get; set; } = new List<Trucking>();
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
};
}

View File

@ -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<Trucking> Truckings { get; set; } = new List<Trucking>();
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
};
}

View File

@ -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<Trucking> Truckings { get; set; } = new List<Trucking>();
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
};
}

View File

@ -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
};
}

View File

@ -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<Trucking> Truckings { get; set; } = new List<Trucking>();
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
};
}