PIbd-21_CourseWork_Polyclin.../Polyclinic/PolyclinicDatabaseImplement/Models/Diagnose.cs

53 lines
1.4 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; private set; } = string.Empty;
[Required]
public string Comment { get; private set; } = string.Empty;
[Required]
public int UserId { get; private set; }
public int Id { get; private set; }
public virtual User? User { get; private set; }
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
};
}
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
};
}
}