2023-04-22 19:42:51 +04:00
|
|
|
|
using Contracts.BindingModels;
|
|
|
|
|
using Contracts.ViewModels;
|
|
|
|
|
using DataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2023-05-05 21:47:09 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2023-04-22 19:42:51 +04:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace DataBase;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Таблица машин
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class Car : ICar
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Айди машины
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Модель машины
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Model { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Грузоподъемность
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Tonnage { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Статус машины
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int? StatusId { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual Status? Status { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual ICollection<Voyage> Voyages { get; set; } = new List<Voyage>();
|
2023-05-05 21:47:09 +04:00
|
|
|
|
[NotMapped]
|
|
|
|
|
public string? StatusTitle { get; set; } = string.Empty;
|
|
|
|
|
|
2023-04-22 19:42:51 +04:00
|
|
|
|
|
|
|
|
|
public static Car Create(LogisticContext context, CarBM model)
|
|
|
|
|
{
|
|
|
|
|
return new Car()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Model = model.Model,
|
|
|
|
|
Tonnage = model.Tonnage,
|
|
|
|
|
StatusId= model.StatusId,
|
2023-05-05 21:47:09 +04:00
|
|
|
|
StatusTitle = model.StatusTitle,
|
2023-04-22 19:42:51 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(CarBM model)
|
|
|
|
|
{
|
|
|
|
|
Model = model.Model;
|
|
|
|
|
Tonnage = model.Tonnage;
|
|
|
|
|
StatusTitle = model.StatusTitle;
|
|
|
|
|
StatusId = model.StatusId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CarVM GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Model = Model,
|
|
|
|
|
Tonnage = Tonnage,
|
|
|
|
|
StatusId = StatusId ,
|
2023-05-05 21:47:09 +04:00
|
|
|
|
StatusTitle = Status?.Title
|
2023-04-22 19:42:51 +04:00
|
|
|
|
};
|
|
|
|
|
}
|