2023-04-05 23:24:58 +04:00
|
|
|
|
using HospitalContracts.BindingModels;
|
|
|
|
|
using HospitalContracts.ViewModels;
|
|
|
|
|
using HospitalDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2023-04-07 00:53:55 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2023-04-05 23:24:58 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace HospitalDataBaseImplements.Models
|
|
|
|
|
{
|
|
|
|
|
public class Medicines : IMedicinesModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string MedicinesName { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public string Group { get; private set; } = string.Empty;
|
|
|
|
|
public static Medicines? Create(MedicinesBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Medicines()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
MedicinesName = model.MedicinesName,
|
|
|
|
|
Group = model.Group
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public static Medicines Create(MedicinesViewModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Medicines
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
MedicinesName = model.MedicinesName,
|
|
|
|
|
Group = model.Group
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(MedicinesBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MedicinesName = model.MedicinesName;
|
|
|
|
|
Group = model.Group;
|
|
|
|
|
}
|
|
|
|
|
public MedicinesViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
MedicinesName = MedicinesName,
|
|
|
|
|
Group = Group
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|