56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using VeterinaryClinicContracts.BindingModels;
|
|
using VeterinaryClinicContracts.ViewModels;
|
|
using VeterinaryClinicDataModels.Models;
|
|
|
|
namespace VeterinaryClinicDatabaseImplement.Models
|
|
{
|
|
public class Medication: IMedicationModel
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
public string Description { get; set; } = string.Empty;
|
|
|
|
public static Medication? Create(MedicationBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return new Medication()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
Description = model.Description
|
|
};
|
|
}
|
|
|
|
public void Update(MedicationBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Name = model.Name;
|
|
Description = model.Description;
|
|
}
|
|
|
|
public MedicationViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
Description = Description
|
|
};
|
|
}
|
|
}
|