2023-04-13 00:10:37 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2023-04-13 00:49:02 +04:00
|
|
|
|
using TransportCompanyContracts.BindingModels;
|
|
|
|
|
using TransportCompanyContracts.ViewModels;
|
|
|
|
|
using TransportCompanyDataModels.Models;
|
2023-04-13 00:10:37 +04:00
|
|
|
|
|
|
|
|
|
namespace TransportCompanyDatabaseImplements.Models;
|
|
|
|
|
|
2023-04-13 00:49:02 +04:00
|
|
|
|
public partial class Trucking : ITruckingModel
|
2023-04-13 00:10:37 +04:00
|
|
|
|
{
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
public int ClientId { get; set; }
|
|
|
|
|
|
|
|
|
|
public int CargoId { get; set; }
|
|
|
|
|
|
2023-04-13 00:49:02 +04:00
|
|
|
|
public double Price { get; set; }
|
2023-04-13 00:10:37 +04:00
|
|
|
|
|
2023-04-13 00:49:02 +04:00
|
|
|
|
public DateTime DateStart { get; set; }
|
2023-04-13 00:10:37 +04:00
|
|
|
|
|
2023-04-13 00:49:02 +04:00
|
|
|
|
public DateTime DateEnd { get; set; }
|
2023-04-13 00:10:37 +04:00
|
|
|
|
|
2023-04-13 00:49:02 +04:00
|
|
|
|
public int TransportationId { get; set; }
|
2023-04-13 00:10:37 +04:00
|
|
|
|
|
|
|
|
|
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!;
|
2023-04-13 00:49:02 +04:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
};
|
2023-04-13 00:10:37 +04:00
|
|
|
|
}
|