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; } public int Id { get; set; } public virtual User? User { get; 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 }; } }