LabSubd/Subd/DataBase/Route.cs

71 lines
1.5 KiB
C#

using Contracts.BindingModels;
using Contracts.ViewModels;
using DataModels.Models;
using System;
using System.Collections.Generic;
namespace DataBase;
/// <summary>
/// Таблица маршрутов
/// </summary>
public partial class Route : IRoute
{
/// <summary>
/// Айди маршрутта
/// </summary>
public int Id { get; set; }
/// <summary>
/// Протяженность маршрута
/// </summary>
public int Length { get; set; }
/// <summary>
/// Места прибытия
/// </summary>
public int? PlaceStart { get; set; }
/// <summary>
/// Места отправки
/// </summary>
public int? PlaceEnd { get; set; }
public virtual Place? PlaceEndNavigation { get; set; }
public virtual Place? PlaceStartNavigation { get; set; }
public virtual ICollection<Voyage> Voyages { get; set; } = new List<Voyage>();
public string Title { get; set; }=string.Empty;
public static Route Create(LogisticContext context, RouteBM model)
{
return new Route()
{
Id = model.Id,
Title = model.Title,
Length = model.Length,
PlaceStart = model.PlaceStart,
PlaceEnd = model.PlaceEnd,
};
}
public void Update(RouteBM model)
{
Title = model.Title;
}
public RouteVM GetViewModel => new()
{
Id = Id,
Title = Title,
Length = Length,
PlaceStart = PlaceStart,
PlaceEnd = PlaceEnd,
};
}