using System;
using System.Collections.Generic;
using TaskTrackerContracts.BindingModels;
using TaskTrackerContracts.ViewModels;
namespace TaskTrackerDatabaseImplement;
///
/// Сущность "Проект"
///
public partial class Project
{
///
/// Идентификатор сущности "Проект"
///
public int Id { get; set; }
///
/// Название проекта
///
public string Name { get; set; } = null!;
///
/// Статус проекта
///
public string State { get; set; } = null!;
///
/// Ссылка на компанию, делающая проект
///
public int CompanyId { get; set; }
public virtual Company Company { get; set; } = null!;
public virtual ICollection Tasks { get; set; } = new List();
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
};
}