Task_Tracker_SUBD/TaskTrackerRestAPI/TaskTrackerDatabaseImplement/Company.cs
2023-05-17 10:48:52 +04:00

75 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using TaskTrackerContracts.BindingModels;
using TaskTrackerContracts.ViewModels;
namespace TaskTrackerDatabaseImplement;
/// <summary>
/// Сущность &quot;Компания&quot;
/// </summary>
public partial class Company
{
/// <summary>
/// Идентификатор сущности &quot;Компания&quot;
/// </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
};
}