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

56 lines
1.5 KiB
C#

using PolyclinicContracts.BindingModels;
using PolyclinicContracts.ViewModels;
using PolyclinicDataModels.Models;
using SecuritySystemDatabaseImplement;
using System.ComponentModel.DataAnnotations;
namespace PolyclinicDatabaseImplement.Models
{
public class Medicament : IMedicamentModel
{
public int Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public string Comment { get; set; } = string.Empty;
[Required]
public int ProcedureId { get; set; }
[Required]
public int SymptomId { get; set; }
public virtual Symptom? Symptom { get; set; }
public virtual Procedure? Procedure { get; set; }
public static Medicament Create(MedicamentBindingModel bindingModel)
{
return new Medicament()
{
Id = bindingModel.Id,
Name = bindingModel.Name,
Comment = bindingModel.Comment,
ProcedureId = bindingModel.ProcedureId,
SymptomId = bindingModel.SymptomId
};
}
public void Update(MedicamentBindingModel bindingModel)
{
Name = bindingModel.Name;
Comment = bindingModel.Comment;
}
public MedicamentViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Comment = Comment,
ProcedureId = ProcedureId,
SymptomId = SymptomId
};
}
}