using Contracts.BindingModels; using Contracts.SearchModel; using Contracts.ViewModels; using DataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; namespace DataBase; /// /// Таблица водителей /// public partial class Human : IHuman { /// /// Айди человека /// public int Id { get; set; } /// /// ФИО водителя /// public string Name { get; set; } = null!; /// /// Телефон водителя /// public string Phone { get; set; } = null!; /// /// Статус водителя /// public int? StatusId { get; set; } public virtual Status? Status { get; set; } public virtual ICollection Voyages { get; set; } = new List(); [NotMapped] public string? StatusTitle { get; set; } = string.Empty; public static Human Create(LogisticContext context, HumanBM model) { return new Human() { Id = model.Id, Name = model.Name, Phone = model.Phone, StatusId = model.StatusId, StatusTitle = model.StatusTitle }; } public void Update(HumanBM model) { Name = model.Name; Phone = model.Phone; StatusTitle = model.StatusTitle; StatusId = model.StatusId; } public HumanVM GetViewModel => new() { Id = Id, Name = Name, Phone = Phone, StatusId = StatusId, StatusTitle = Status?.Title }; }