74 lines
2.0 KiB
C#
74 lines
2.0 KiB
C#
using CarCenterContracts.BindingModels;
|
|
using CarCenterContracts.ViewModels;
|
|
using CarCenterDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CarCenterDatabaseImplement.Models
|
|
{
|
|
public class Employee : IEmployeeModel
|
|
{
|
|
public int Id { get; set; }
|
|
public string Login {get; set;} = string.Empty;
|
|
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
public string Surname { get; set; } = string.Empty;
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
public string? Patronymic { get; set; }
|
|
public static Employee? Create(EmployeeBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Employee()
|
|
{
|
|
Id = model.Id,
|
|
Login = model.Login,
|
|
Password = model.Password,
|
|
Surname = model.Surname,
|
|
Name = model.Name,
|
|
Patronymic = model.Patronymic,
|
|
};
|
|
}
|
|
public static Employee? Create(EmployeeViewModel model)
|
|
{
|
|
return new Employee()
|
|
{
|
|
Id = model.Id,
|
|
Login = model.Login,
|
|
Password = model.Password,
|
|
Surname = model.Surname,
|
|
Name = model.Name,
|
|
Patronymic = model.Patronymic,
|
|
};
|
|
}
|
|
public void Update(EmployeeBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Password = model.Password;
|
|
Surname = model.Surname;
|
|
Name = model.Name;
|
|
Patronymic = model.Patronymic;
|
|
}
|
|
public EmployeeViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Login = Login,
|
|
Password = Password,
|
|
Surname = Surname,
|
|
Name = Name,
|
|
Patronymic = Patronymic,
|
|
};
|
|
}
|
|
}
|