using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZooContracts.BindingModels;
using ZooContracts.ViewModels;
using ZooDataModels.Models;

namespace ZooDatabaseImplements.Models
{
    public class Employee : IEmployeeModel
    {
        public int Id { get; set; }
        [Required]
        public string EmployeePhone { get; set; } = string.Empty;
        [Required]
        public string EmployeeEmail { get; set; } = string.Empty;
        [Required]
        public string EmployeePassword { get; set; } = string.Empty;
        [Required]
        public string EmployeeName { get; set; } = string.Empty;
        [ForeignKey("EmployeeId")]
        public virtual List<Cost> Costs { get; set; } = new();
        [ForeignKey("CostId")]
        public virtual List<Reserve> Reserves { get; set; } = new();
        public static Employee? Create(EmployeeBindingModel model)
        {
            if (model == null)
            {
                return null;
            }
            return new()
            {
                Id = model.Id,
                EmployeeName = model.EmployeeName,
                EmployeeEmail = model.EmployeeEmail,
                EmployeePassword = model.EmployeePassword,
                EmployeePhone = model.EmployeePhone
            };
        }
        public void Update(EmployeeBindingModel model)
        {
            if (model == null)
            {
                return;
            }
            EmployeeName = model.EmployeeName;
            EmployeeEmail = model.EmployeeEmail;
            EmployeePassword = model.EmployeePassword;
            EmployeePhone = model.EmployeePhone;
        }

        public EmployeeViewModel GetViewModel => new()
        {
            Id = Id,
            EmployeeName = EmployeeName,
            EmployeeEmail = EmployeeEmail,
            EmployeePassword = EmployeePassword,
            EmployeePhone = EmployeePhone
        };
    }
}
