CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Employee.cs

62 lines
1.6 KiB
C#
Raw Normal View History

2024-05-25 13:06:38 +04:00
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; }
2024-05-25 22:32:22 +04:00
2024-05-25 13:06:38 +04:00
[Required]
2024-05-25 22:32:22 +04:00
public string EmployeeFIO { get; set; } = string.Empty;
2024-05-25 13:06:38 +04:00
[Required]
public string Login { get; set; } = string.Empty;
2024-05-25 22:32:22 +04:00
2024-05-25 13:06:38 +04:00
[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,
};
}
2024-05-25 22:32:22 +04:00
public void Update(EmployeeBindingModel? model)
2024-05-25 13:06:38 +04:00
{
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,
};
}
}