2024-04-28 12:53:41 +04:00
|
|
|
|
using PolyclinicContracts.BindingModels;
|
|
|
|
|
using PolyclinicContracts.ViewModels;
|
|
|
|
|
using PolyclinicDataModels.Models;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace PolyclinicDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Diagnose : IDiagnoseModel
|
|
|
|
|
{
|
|
|
|
|
[Required]
|
2024-04-28 16:09:47 +04:00
|
|
|
|
public string Name { get; set; } = string.Empty;
|
2024-05-26 13:03:03 +04:00
|
|
|
|
public string? Comment { get; set; }
|
2024-04-28 12:53:41 +04:00
|
|
|
|
[Required]
|
2024-04-28 16:09:47 +04:00
|
|
|
|
public int UserId { get; set; }
|
2024-05-01 10:33:00 +04:00
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public DateTime DateStartDiagnose { get; set; } = DateTime.Now;
|
|
|
|
|
public DateTime? DateStopDiagnose { get; set; }
|
2024-04-28 16:09:47 +04:00
|
|
|
|
public int Id { get; set; }
|
2024-05-29 13:55:20 +04:00
|
|
|
|
public virtual User? User { get; set; }
|
2024-04-28 12:55:26 +04:00
|
|
|
|
|
2024-04-28 12:53:41 +04:00
|
|
|
|
public static Diagnose? Create(DiagnoseBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Diagnose
|
|
|
|
|
{
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
Comment = model.Comment,
|
|
|
|
|
UserId = model.UserId,
|
2024-05-01 10:33:00 +04:00
|
|
|
|
Id = model.Id,
|
|
|
|
|
DateStartDiagnose = model.DateStartDiagnose,
|
|
|
|
|
DateStopDiagnose = model.DateStopDiagnose,
|
2024-04-28 12:53:41 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(DiagnoseBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Name = model.Name;
|
|
|
|
|
Comment = model.Comment;
|
2024-05-26 14:49:08 +04:00
|
|
|
|
DateStartDiagnose = model.DateStartDiagnose;
|
|
|
|
|
DateStopDiagnose = model.DateStopDiagnose;
|
2024-04-28 12:53:41 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DiagnoseViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Name = Name,
|
|
|
|
|
Comment = Comment,
|
|
|
|
|
UserId = UserId,
|
2024-05-01 10:33:00 +04:00
|
|
|
|
Id = Id,
|
|
|
|
|
DateStartDiagnose = DateStartDiagnose,
|
|
|
|
|
DateStopDiagnose = DateStopDiagnose,
|
2024-04-28 12:53:41 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|