LabSubd/Subd/DataBase/Human.cs

69 lines
1.6 KiB
C#

using Contracts.BindingModels;
using Contracts.SearchModel;
using Contracts.ViewModels;
using DataModels.Models;
using System;
using System.Collections.Generic;
namespace DataBase;
/// <summary>
/// Таблица водителей
/// </summary>
public partial class Human : IHuman
{
/// <summary>
/// Айди человека
/// </summary>
public int Id { get; set; }
/// <summary>
/// ФИО водителя
/// </summary>
public string Name { get; set; } = null!;
/// <summary>
/// Телефон водителя
/// </summary>
public string Phone { get; set; } = null!;
/// <summary>
/// Статус водителя
/// </summary>
public int? StatusId { get; set; }
public virtual Status? Status { get; set; }
public virtual ICollection<Voyage> Voyages { get; set; } = new List<Voyage>();
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 = StatusTitle
};
}