56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
|
using HospitalContracts.BindingModels;
|
|||
|
using HospitalContracts.ViewModels;
|
|||
|
using HospitalDataModels.Models;
|
|||
|
using SecuritySystemDatabaseImplement;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
|
|||
|
namespace HospitalDatabaseImplement.Models
|
|||
|
{
|
|||
|
public class Drug : IDrugModel
|
|||
|
{
|
|||
|
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 Drug Create(DrugBindingModel bindingModel)
|
|||
|
{
|
|||
|
return new Drug()
|
|||
|
{
|
|||
|
Id = bindingModel.Id,
|
|||
|
Name = bindingModel.Name,
|
|||
|
Comment = bindingModel.Comment,
|
|||
|
ProcedureId = bindingModel.ProcedureId,
|
|||
|
SymptomId = bindingModel.SymptomId
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(DrugBindingModel bindingModel)
|
|||
|
{
|
|||
|
Name = bindingModel.Name;
|
|||
|
Comment = bindingModel.Comment;
|
|||
|
}
|
|||
|
|
|||
|
public DrugViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
Name = Name,
|
|||
|
Comment = Comment,
|
|||
|
ProcedureId = ProcedureId,
|
|||
|
SymptomId = Symptom?.Id ?? null
|
|||
|
};
|
|||
|
}
|
|||
|
}
|