using HospitalContracts.BindingModels;
using HospitalContracts.ViewModels;
using HospitalDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HospitalDatabaseImplement.Models
{
///
/// Сущность "Лекарство"
///
public class Medicine : IMedicineModel
{
///
/// Идентификатор
///
public int Id { get; private set; }
///
/// Название лекарства
///
[Required]
[MaxLength(30)]
public string Name { get; private set; } = string.Empty;
///
/// Описание лекарства
///
[MaxLength(100)]
public string? Description { get; private set; }
///
/// Создать сущность
///
///
///
public static Medicine? Create(MedicineBindingModel model)
{
if (model == null)
{
return null;
}
return new Medicine()
{
Id = model.Id,
Name = model.Name,
Description = model.Description
};
}
///
/// Изменить сущность
///
///
public void Update(MedicineBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
Description = model.Description;
}
///
/// Получить модель представления
///
public MedicineViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Description = Description
};
}
}