85 lines
2.2 KiB
C#
85 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TaskTrackerContracts.BindingModels;
|
|
using TaskTrackerContracts.ViewModels;
|
|
using TaskTrackerDataModels.Enums;
|
|
using TaskTrackerDataModels.Models;
|
|
|
|
namespace TaskTrackerDatabase.Models
|
|
{
|
|
public class Task : ITaskModel
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public int ProjectId { get; set; }
|
|
|
|
[Required]
|
|
public int UserId { get; set; }
|
|
|
|
[Required]
|
|
public string Title { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Description { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public MyTaskStatus Status { get; set; }
|
|
|
|
[Required]
|
|
public DateTime DateCreate { get; set; }
|
|
|
|
public DateTime? DateImplement { get; set; }
|
|
|
|
public virtual Project Project { get; set; }
|
|
public virtual User User { get; set; }
|
|
|
|
public static Task? Create(TaskBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Task()
|
|
{
|
|
Id = model.Id,
|
|
ProjectId = model.ProjectId,
|
|
UserId = model.UserId,
|
|
Title = model.Title,
|
|
Description = model.Description,
|
|
Status = model.Status,
|
|
DateCreate = model.DateCreate,
|
|
DateImplement = model.DateImplement
|
|
};
|
|
}
|
|
|
|
public void Update(TaskBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Status = model.Status;
|
|
DateImplement = model.DateImplement;
|
|
}
|
|
|
|
public TaskViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
ProjectId = ProjectId,
|
|
UserId = UserId,
|
|
Title = Title,
|
|
Description = Description,
|
|
Status = Status,
|
|
DateCreate = DateCreate,
|
|
DateImplement = DateImplement,
|
|
ProjectName = Project.ProjectName,
|
|
UserFIO = User.UserFIO
|
|
};
|
|
}
|
|
}
|