using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
using static System.Runtime.InteropServices.JavaScript.JSType;
using VetClinicContracts.BindingModels;
using VetClinicContracts.ViewModels;
using VetClinicDataModels.Models;

namespace VetClinicDataBaseImplement.Models
{
	public class Vaccination : IVaccinationModel
	{
		public int Id { get; private set; }
		[Required]
		public int AnimalId { get; private set; }
		public virtual Animal Animal { get; private set; }
		[Required]
		public string NameVaccination { get; private set; } = string.Empty;
		[Required]
		public double CostVaccination { get; private set; }
		[Required]
		public DateTime? DateStamp { get; private set; }
		public static Vaccination? Create(VetClinicDatabase context, VaccinationBindingModel model)
		{
			if (model == null)
			{
				return null;
			}
			return new Vaccination()
			{
				Id = model.Id,
				AnimalId = model.AnimalId,
				NameVaccination = model.NameVaccination,
				CostVaccination = model.CostVaccination,
				DateStamp = model.DateStamp,

			};
		}

		public void Update(VaccinationBindingModel? model)
		{
			if (model == null)
			{
				return;
			}
			NameVaccination = model.NameVaccination;
			CostVaccination = model.CostVaccination;
			DateStamp = model.DateStamp;
			
		}
	
		public VaccinationViewModel GetViewModel => new()
		{
			AnimalId = AnimalId,
			NameVaccination = NameVaccination,
			DateStamp = DateStamp,
			Id = Id,
			AnimalName = Animal.AnimalName
		};
	}
}
