using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.ViewModels;
using ElectronicsShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ElectronicsShopDataBaseImplement.Models
{
    public class Employee : IEmployeeModel
    {
        public int ID { get; set; }

        [Required]
        public string EmployeeFIO { get; set; } = string.Empty;

        [Required]
        public string Login { get; set; } = string.Empty;

        [Required]
        public string Password { get; set; } = string.Empty;

        public static Employee? Create(EmployeeBindingModel? model)
        {
            if (model == null)
            {
                return null;
            }
            return new Employee()
            {
                ID = model.ID,
                EmployeeFIO = model.EmployeeFIO,
                Login = model.Login,
                Password = model.Password,
            };
        }
        public void Update(EmployeeBindingModel? model)
        {
            if (model == null)
            {
                return;
            }
            EmployeeFIO = model.EmployeeFIO;
            Login = model.Login;
            Password = model.Password;
        }

        public EmployeeViewModel GetViewModel => new()
        {
            ID = ID,
            EmployeeFIO = EmployeeFIO,
            Login = Login,
            Password = Password,
        };
    }
}