60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using BankContracts.BindingModels;
|
|
using BankContracts.ViewModels;
|
|
using BankDataModels;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace BankDatabaseImplement.Models
|
|
{
|
|
public class Employee : IEmployeeModel
|
|
{
|
|
public int Id { get; private set; }
|
|
[Required]
|
|
public string FirstName { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string LastName { get; private set; } = string.Empty;
|
|
public string? MiddleName { get; private set; }
|
|
[Required]
|
|
public string Post { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string PhoneNumber { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string Password { get; private set; } = string.Empty;
|
|
[Required]
|
|
public string Email { get; set; } = string.Empty;
|
|
[Required]
|
|
public List<Operation>? Operations { get; private set; }
|
|
[Required]
|
|
public List<Cost>? Costs { get; private set; }
|
|
|
|
public static Employee Create(EmployeeBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Employee()
|
|
{
|
|
FirstName = model.FirstName,
|
|
LastName = model.LastName,
|
|
MiddleName = model.MiddleName,
|
|
PhoneNumber = model.PhoneNumber,
|
|
Password = model.Password,
|
|
Id = model.Id,
|
|
Post = model.Post,
|
|
Email = model.Email,
|
|
};
|
|
}
|
|
|
|
public EmployeeViewModel GetViewModel => new()
|
|
{
|
|
FirstName = FirstName,
|
|
LastName = LastName,
|
|
MiddleName = MiddleName,
|
|
PhoneNumber = PhoneNumber,
|
|
Password = Password,
|
|
Id = Id,
|
|
Post = Post,
|
|
Email = Email,
|
|
};
|
|
}
|
|
} |