using DressAtelierContracts.BindingModels;
using DressAtelierContracts.ViewModels;
using DressAtelierDatabaseImplementation.Models;
using DressAtelierDataModels.Models;
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 System.Xml.Linq;

namespace DressAtelierDatabaseImplement.Models
{
    public class Client : IClientModel
    {
        public int ID { get; private set; }
        [Required]
        public string FullName { get; private set; } = string.Empty;
        [Required]
        public string Email { get; private set; } = string.Empty;
        [Required]
        public string Password { get; private set; } = string.Empty;

        [ForeignKey("ClientID")]
        public virtual List<Order> Orders { get; set; } = new();

        public static Client? Create(ClientBindingModel? model)
        {
            if (model == null)
            {
                return null;
            }
            return new Client()
            {
                ID = model.ID,
                FullName = model.FullName,
                Email = model.Email,
                Password = model.Password
            };
        }       

        public void Update(ClientBindingModel? model)
        {
            if (model == null) { return; }
            FullName = model.FullName;
            Email = model.Email;
            Password = model.Password;
        }

        public ClientViewModel GetViewModel => new()
        {
            ID = ID,
            FullName = FullName,
            Email = Email,
            Password = Password
        };
 
    }
}
