66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using ConstructionFirmDataModels.Models;
|
|
using Subd_4.BindingModels;
|
|
using Subd_4.ViewModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ConstructionFirmDatabaseImplement.Models
|
|
{
|
|
public class Employee : IEmployeeModel
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public string FullName { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Phone { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public DateTime HireDate { get; set; }
|
|
|
|
public int TeamId { get; set; }
|
|
|
|
public int SpecialtyId { get; set; }
|
|
|
|
public static Employee? Create(EmployeeBindingModel model)
|
|
{
|
|
if (model == null) return null;
|
|
|
|
return new Employee()
|
|
{
|
|
Id = model.Id,
|
|
FullName = model.FullName,
|
|
Phone = model.Phone,
|
|
HireDate = model.HireDate,
|
|
TeamId = model.TeamId,
|
|
SpecialtyId = model.SpecialtyId
|
|
};
|
|
}
|
|
|
|
public void Update(EmployeeBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
FullName = model.FullName;
|
|
Phone = model.Phone;
|
|
HireDate = model.HireDate;
|
|
TeamId = model.TeamId;
|
|
SpecialtyId = model.SpecialtyId;
|
|
}
|
|
|
|
public EmployeeViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
FullName = FullName,
|
|
Phone = Phone,
|
|
HireDate = HireDate,
|
|
TeamId = TeamId,
|
|
SpecialtyId = SpecialtyId
|
|
};
|
|
}
|
|
}
|