75 lines
1.5 KiB
C#
75 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using TaskTrackerContracts.BindingModels;
|
|
using TaskTrackerContracts.ViewModels;
|
|
|
|
namespace TaskTrackerDatabaseImplement;
|
|
|
|
/// <summary>
|
|
/// Сущность "Компания"
|
|
/// </summary>
|
|
public partial class Company
|
|
{
|
|
/// <summary>
|
|
/// Идентификатор сущности "Компания"
|
|
/// </summary>
|
|
public int Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// Название компании
|
|
/// </summary>
|
|
public string Name { get; set; } = null!;
|
|
|
|
public string? Login { get; set; }
|
|
|
|
public string? Password { get; set; }
|
|
|
|
public virtual ICollection<Employee> Employees { get; set; } = new List<Employee>();
|
|
|
|
public virtual ICollection<Project> Projects { get; set; } = new List<Project>();
|
|
public static Company? Create(CompanyBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Company()
|
|
{
|
|
Name = model.Name,
|
|
Password = model.Password,
|
|
Login = model.Login,
|
|
Id = model.Id
|
|
|
|
};
|
|
}
|
|
public static Company Create(CompanyViewModel model)
|
|
{
|
|
return new Company()
|
|
{
|
|
Name = model.Name,
|
|
Password = model.Password,
|
|
Login = model.Login,
|
|
Id = model.Id
|
|
};
|
|
}
|
|
public void Update(CompanyBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Name = model.Name;
|
|
Password = model.Password;
|
|
Login = model.Login;
|
|
}
|
|
public CompanyViewModel GetViewModel => new()
|
|
{
|
|
Name = Name,
|
|
Password = Password,
|
|
Login = Login,
|
|
Id = Id
|
|
};
|
|
|
|
|
|
}
|