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 VetClinicContracts.BindingModels;
using VetClinicContracts.ViewModels;
using VetClinicDataModels.Models;

namespace VetClinicDataBaseImplement.Models
{
	public class Pharmacist : IPharmacistModel
	{
		public int Id { get; private set; }
		[Required]
		public string PharmacistFIO { get; private set; } = string.Empty;
		[Required]
		public string Email { get; set; } = string.Empty;
		[Required]
		public string Password { get; set; } = string.Empty;
		[ForeignKey("PharmacistId")]
		public virtual List<Medicine> Medicines { get; set; } =
	   new();
		[ForeignKey("PharmacistId")]
		public virtual List<Service> Services { get; set; } =
	   new();

		public static Pharmacist? Create(PharmacistBindingModel model)
		{
			if (model == null)
			{
				return null;
			}
			return new Pharmacist()
			{
				Id = model.Id,
				PharmacistFIO = model.PharmacistFIO,
				Email = model.Email,
				Password = model.Password
			};
		}

		public static Pharmacist Create(PharmacistViewModel model)
        {
            return new Pharmacist()
            {
                Id = model.Id,
                PharmacistFIO = model.PharmacistFIO,
                Email = model.Email,
                Password = model.Password
            };
        }
        public void Update( PharmacistBindingModel model)
        {
            if (model == null)
            {
                return;
            }
			PharmacistFIO = model.PharmacistFIO;
            Email = model.Email;
            Password = model.Password;
        }
        public PharmacistViewModel GetViewModel => new()
        {
            Id = Id,
            PharmacistFIO = PharmacistFIO,
            Email = Email,
            Password = Password
        };
	}
}
