61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
using PolyclinicContracts.BindingModels;
|
|
using PolyclinicContracts.ViewModels;
|
|
using PolyclinicDataModels.Models;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace PolyclinicDatabaseImplement.Models
|
|
{
|
|
public class Diagnose : IDiagnoseModel
|
|
{
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
[Required]
|
|
public string Comment { get; set; } = string.Empty;
|
|
[Required]
|
|
public int UserId { get; set; }
|
|
|
|
[Required]
|
|
public DateTime DateStartDiagnose { get; set; } = DateTime.Now;
|
|
public DateTime? DateStopDiagnose { get; set; }
|
|
public int Id { get; set; }
|
|
public virtual User User { get; set; } = new();
|
|
|
|
public static Diagnose? Create(DiagnoseBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Diagnose
|
|
{
|
|
Name = model.Name,
|
|
Comment = model.Comment,
|
|
UserId = model.UserId,
|
|
Id = model.Id,
|
|
DateStartDiagnose = model.DateStartDiagnose,
|
|
DateStopDiagnose = model.DateStopDiagnose,
|
|
};
|
|
}
|
|
|
|
public void Update(DiagnoseBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Name = model.Name;
|
|
Comment = model.Comment;
|
|
}
|
|
|
|
public DiagnoseViewModel GetViewModel => new()
|
|
{
|
|
Name = Name,
|
|
Comment = Comment,
|
|
UserId = UserId,
|
|
Id = Id,
|
|
DateStartDiagnose = DateStartDiagnose,
|
|
DateStopDiagnose = DateStopDiagnose,
|
|
};
|
|
}
|
|
}
|