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 Client : IClientModel
    {
        public int Id { get; private set; }
        [Required]
        public string ClientName { get; private set; } = string.Empty;
        [Required]
        public string ClientPhone { get; private set; } = string.Empty;
        [Required]
        public string ClientPassword { get; private set; } = string.Empty;
        [Required]
        public string ClientEmail { get; private set; } = string.Empty;
        [ForeignKey("ClientId")]
        public virtual List<Route> Routes { get; set; } = new();
        public static Client? Create(ClientBindingModel model)
        {
            if (model == null)
            {
                return null;
            }
            return new()
            {
                Id = model.Id,
                ClientName = model.ClientName,
                ClientEmail = model.ClientEmail,
                ClientPassword = model.ClientPassword,
                ClientPhone = model.ClientPhone
            };
        }
        public void Update(ClientBindingModel model)
        {
            if (model == null)
            {
                return;
            }
            ClientName = model.ClientName;
            ClientEmail = model.ClientEmail;
            ClientPassword = model.ClientPassword;
            ClientPhone = model.ClientPhone;
        }
        public ClientViewModel GetViewModel => new()
        {
            Id = Id,
            ClientName = ClientName,
            ClientEmail = ClientEmail,
            ClientPassword = ClientPassword,
            ClientPhone = ClientPhone
        };
    }
}
