74 lines
1.8 KiB
C#
74 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using VeterinaryContracts.BindingModels;
|
|
using VeterinaryContracts.ViewModels;
|
|
using VeterinaryDataModels.Models;
|
|
|
|
namespace VeterinaryDatabaseImplement.Models
|
|
{
|
|
public class Doctor : IDoctorModel
|
|
{
|
|
public int Id { get; private set; }
|
|
[Required]
|
|
public string DoctorFIO { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string Login { get; set; } = string.Empty;
|
|
[Required]
|
|
public string Password { get; set; } = string.Empty;
|
|
[ForeignKey("DoctorId")]
|
|
public virtual List<Service> Services { get; set; } = new();
|
|
[ForeignKey("DoctorId")]
|
|
public virtual List<Medication> Medications { get; set; } = new();
|
|
[ForeignKey("DoctorId")]
|
|
public virtual List<Visit> Visits { get; set; } = new();
|
|
[ForeignKey("DoctorId")]
|
|
public virtual List<Drug> Drugs { get; set; } = new();
|
|
public static Doctor? Create(DoctorBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Doctor()
|
|
{
|
|
Id = model.Id,
|
|
DoctorFIO = model.DoctorFIO,
|
|
Login = model.Login,
|
|
Password = model.Password
|
|
};
|
|
}
|
|
public static Doctor Create(DoctorViewModel model)
|
|
{
|
|
return new Doctor()
|
|
{
|
|
Id = model.Id,
|
|
DoctorFIO = model.DoctorFIO,
|
|
Login = model.Login,
|
|
Password = model.Password
|
|
};
|
|
}
|
|
public void Update(DoctorBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
DoctorFIO = model.DoctorFIO;
|
|
Login = model.Login;
|
|
Password = model.Password;
|
|
}
|
|
public DoctorViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
DoctorFIO = DoctorFIO,
|
|
Login = Login,
|
|
Password = Password
|
|
};
|
|
}
|
|
}
|