using BankContracts.BindingModels;
using BankContracts.ViewModels;
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BankDatabaseImplement.Models
{
    public class BankOperator : IBankOperatorModel
    {
        public int Id { get; set; }
        public string Login { get; set; } = string.Empty;
        public string Password { get; set; } = string.Empty;
        public string FirstName { get; set; } = string.Empty;
        public string LastName { get; set; } = string.Empty;
        public string? MiddleName {get; set; }

        public static BankOperator? Create(BankOperatorBindingModel model)
        {
            if (model == null)
            {
                return null;
            }
            return new BankOperator()
            {
                Id = model.Id,
                Login = model.Login,
                Password = model.Password,
                LastName = model.LastName,
                FirstName = model.FirstName,
                MiddleName = model.MiddleName,
            };
        }
        public static BankOperator? Create(BankOperatorViewModel model)
        {
            return new BankOperator()
            {
                Id = model.Id,
                Login = model.Login,
                Password = model.Password,
                LastName = model.LastName,
                FirstName = model.FirstName,
                MiddleName = model.MiddleName,
            };
        }
        public void Update(BankOperatorBindingModel? model)
        {
            if (model == null)
            {
                return;
            }
            Password = model.Password;
            Login = model.Login;
            LastName = model.LastName;
            FirstName = model.FirstName;
            MiddleName = model.MiddleName;
        }
        public BankOperatorViewModel GetViewModel => new()
        {
            Id = Id,
            Login = Login,
            Password = Password,
            LastName = LastName,
            FirstName = FirstName,
            MiddleName = MiddleName,
        };

    }
}
