LabSubd/Subd/DataBase/Company.cs

61 lines
1.4 KiB
C#
Raw Normal View History

using Contracts.BindingModels;
using Contracts.ViewModels;
using DataModels.Models;
using System;
using System.Collections.Generic;
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>();
public string StatusTitle { get; set; } = string.Empty;
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,
StatusTitle = StatusTitle
};
}