80 lines
1.6 KiB
C#
80 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using TaskTrackerContracts.BindingModels;
|
|
using TaskTrackerContracts.ViewModels;
|
|
|
|
namespace TaskTrackerDatabaseImplement;
|
|
|
|
/// <summary>
|
|
/// Сущность "Проект"
|
|
/// </summary>
|
|
public partial class Project
|
|
{
|
|
/// <summary>
|
|
/// Идентификатор сущности "Проект"
|
|
/// </summary>
|
|
public int Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// Название проекта
|
|
/// </summary>
|
|
public string Name { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Статус проекта
|
|
/// </summary>
|
|
public string State { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Ссылка на компанию, делающая проект
|
|
/// </summary>
|
|
public int CompanyId { get; set; }
|
|
|
|
public virtual Company Company { get; set; } = null!;
|
|
|
|
public virtual ICollection<Task> Tasks { get; set; } = new List<Task>();
|
|
public static Project? Create(ProjectBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Project()
|
|
{
|
|
Name = model.Name,
|
|
State = model.State,
|
|
CompanyId = model.CompanyId,
|
|
Id = model.Id
|
|
|
|
};
|
|
}
|
|
public static Project Create(ProjectViewModel model)
|
|
{
|
|
return new Project()
|
|
{
|
|
Name = model.Name,
|
|
State = model.State,
|
|
CompanyId = model.CompanyId,
|
|
Id = model.Id
|
|
};
|
|
}
|
|
public void Update(ProjectBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Name = model.Name;
|
|
State = model.State;
|
|
CompanyId = model.CompanyId;
|
|
|
|
}
|
|
public ProjectViewModel GetViewModel => new()
|
|
{
|
|
Name = Name,
|
|
State = State,
|
|
CompanyId = CompanyId,
|
|
Id = Id
|
|
};
|
|
}
|