using BarContracts.BindingModels;
using BarContracts.ViewModels;
using BarDataModels.Models;

namespace BarListImplement.Models
{
    public class Client : IClientModel
    {
        public int Id { get; private set; }
        
        public string ClientFIO { get; private set; } = string.Empty;
        
        public string Email { get; set; } = string.Empty;
        
        public string Password { get; set; } = string.Empty;
        
        public static Client? Create(ClientBindingModel Model)
        {
            if (Model == null)
                return null;

            return new Client()
            {
                Id = Model.Id,
                ClientFIO = Model.ClientFIO,
                Email = Model.Email,
                Password = Model.Password
            };
        }
        
        public void Update(ClientBindingModel Model)
        {
            if (Model == null)
                return;

            ClientFIO = Model.ClientFIO;
            Email = Model.Email;
            Password = Model.Password;
        }
        
        public ClientViewModel GetViewModel => new()
        {
            Id = Id,
            ClientFIO = ClientFIO,
            Email = Email,
            Password = Password
        };
    }
}
