using Contracts.BindingModels;
using Contracts.ViewModels;
using DataModels.Models;
using System;
using System.Collections.Generic;
namespace DataBase;
///
/// Таблица рейсов
///
public partial class Voyage : IVoyage
{
///
/// Айди рейса
///
public int Id { get; set; }
///
/// Машина для рейса
///
public int? CarId { get; set; }
///
/// Водитель для рейса
///
public int? HumanId { get; set; }
///
/// Компания, заказавшая рейс
///
public int? CompanyId { get; set; }
///
/// Маршрут рейса
///
public int? RouteId { get; set; }
///
/// Дата отправки
///
public DateOnly? DateStart { get; set; }
///
/// Дедлайн
///
public DateOnly? DateEnd { get; set; }
public virtual Car? Car { get; set; }
public virtual Company? Company { get; set; }
public virtual Human? Human { get; set; }
public virtual Route? Route { get; set; }
public string CarName { get; set; } = string.Empty;
public string HumanName { get; set; } = string.Empty;
public string CompanyName { get; set; } = string.Empty;
public static Voyage Create(LogisticContext context, VoyageBM model)
{
return new Voyage()
{
Id = model.Id,
CarId=model.CarId,
HumanId=model.HumanId,
CompanyId=model.CompanyId,
RouteId=model.RouteId,
DateStart=model.DateStart,
DateEnd=model.DateEnd,
CarName=model.CarName,
HumanName=model.HumanName,
CompanyName=model.CompanyName,
};
}
public VoyageVM GetViewModel => new()
{
Id = Id,
CarId = CarId,
HumanId = HumanId,
CompanyId = CompanyId,
RouteId = RouteId,
DateStart = DateStart,
DateEnd = DateEnd,
CarName = CarName,
HumanName = HumanName,
CompanyName = CompanyName,
};
}