LabSubd/Subd/DataBase/Voyage.cs

99 lines
2.2 KiB
C#
Raw Normal View History

using Contracts.BindingModels;
using Contracts.ViewModels;
using DataModels.Models;
using System;
using System.Collections.Generic;
namespace DataBase;
/// <summary>
/// Таблица рейсов
/// </summary>
public partial class Voyage : IVoyage
{
/// <summary>
/// Айди рейса
/// </summary>
public int Id { get; set; }
/// <summary>
/// Машина для рейса
/// </summary>
public int? CarId { get; set; }
/// <summary>
/// Водитель для рейса
/// </summary>
public int? HumanId { get; set; }
/// <summary>
/// Компания, заказавшая рейс
/// </summary>
public int? CompanyId { get; set; }
/// <summary>
/// Маршрут рейса
/// </summary>
public int? RouteId { get; set; }
/// <summary>
/// Дата отправки
/// </summary>
public DateOnly? DateStart { get; set; }
/// <summary>
/// Дедлайн
/// </summary>
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,
};
}