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
|
|
|
|
|
|
|
|
|
namespace DataBase;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Таблица компаний-заказчиков
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class Company : ICompany
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Айди компании
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Наимнование компании
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Title { 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>();
|
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 Company Create(LogisticContext context, CompanyBM model)
|
|
|
|
|
{
|
|
|
|
|
return new Company()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Title = model.Title,
|
|
|
|
|
StatusId = model.StatusId,
|
|
|
|
|
StatusTitle=model.StatusTitle
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(CompanyBM model)
|
|
|
|
|
{
|
|
|
|
|
Title = model.Title;
|
|
|
|
|
StatusTitle = model.StatusTitle;
|
|
|
|
|
StatusId = model.StatusId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CompanyVM GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Title = Title,
|
|
|
|
|
StatusId = StatusId,
|
2023-05-05 21:47:09 +04:00
|
|
|
|
StatusTitle = Status?.Title
|
2023-04-22 19:42:51 +04:00
|
|
|
|
};
|
|
|
|
|
}
|