using Contracts.BindingModels; using Contracts.ViewModels; using DataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; namespace DataBase; /// /// Таблица маршрутов /// public partial class Route : IRoute { /// /// Айди маршрутта /// public int Id { get; set; } /// /// Протяженность маршрута /// public int Length { get; set; } /// /// Места прибытия /// public int? PlaceStart { get; set; } /// /// Места отправки /// public int? PlaceEnd { get; set; } public virtual Place? PlaceEndNavigation { get; set; } public virtual Place? PlaceStartNavigation { get; set; } public virtual ICollection Voyages { get; set; } = new List(); [NotMapped] 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, Length = Length, PlaceStart = PlaceStart, PlaceEnd = PlaceEnd, Title = PlaceStartNavigation?.Title + " - " + PlaceEndNavigation?.Title }; }