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

namespace BankDatabaseImplement.Models
{
    public class Operator : IOperatorModel
    {
        public int Id { get; set; }
        public string Login {get; set;} = string.Empty;

        public string Password { get; set; } = string.Empty;

        public string LastName { get; set; } = string.Empty;

        public string FirstName { get; set; } = string.Empty;

        public string? MiddleName { get; set; }
        public static Operator? Create(OperatorBindingModel model)
        {
            if (model == null)
            {
                return null;
            }
            return new Operator()
            {
                Id = model.Id,
                Login = model.Login,
                Password = model.Password,
                LastName = model.LastName,
                FirstName = model.FirstName,
                MiddleName = model.MiddleName,
            };
        }
        public static Operator? Create(OperatorViewModel model)
        {
            return new Operator()
            {
                Id = model.Id,
                Login = model.Login,
                Password = model.Password,
                LastName = model.LastName,
                FirstName = model.FirstName,
                MiddleName = model.MiddleName,
            };
        }
        public void Update(OperatorBindingModel? model)
        {
            if (model == null)
            {
                return;
            }
            Password = model.Password;
            LastName = model.LastName;
            FirstName = model.FirstName;
            MiddleName = model.MiddleName;
        }
        public OperatorViewModel GetViewModel => new()
        {
            Id = Id,
            Login = Login,
            Password = Password,
            LastName = LastName,
            FirstName = FirstName,
            MiddleName = MiddleName,
        };
    }
}
