2023-05-02 17:59:19 +04:00
|
|
|
|
using PersonnelDepartmentContracts.BindingModels;
|
|
|
|
|
using PersonnelDepartmentContracts.ViewModels;
|
|
|
|
|
using PersonnelDepartmentDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace PersonnelDepartmentDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Department : IDepartmentModel
|
|
|
|
|
{
|
|
|
|
|
[Required]
|
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
|
[Required]
|
2023-05-02 22:57:54 +04:00
|
|
|
|
public long Telephone { get; set; }
|
2023-05-02 17:59:19 +04:00
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
public static Department? Create(DepartmentBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Department
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Name = model.Name,
|
|
|
|
|
Telephone = model.Telephone
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(DepartmentBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Name = model.Name;
|
|
|
|
|
Telephone = model.Telephone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DepartmentViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Name = Name,
|
|
|
|
|
Telephone = Telephone
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|