48 lines
908 B
C#
48 lines
908 B
C#
|
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 Position : IPositionModel
|
|||
|
{
|
|||
|
[Required]
|
|||
|
public string Name { get; set; } = string.Empty;
|
|||
|
public int Id { get; set; }
|
|||
|
|
|||
|
public static Position? Create(PositionBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
return new Position
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
Name = model.Name
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
public void Update(PositionBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
Name = model.Name;
|
|||
|
}
|
|||
|
|
|||
|
public PositionViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
Name = Name
|
|||
|
};
|
|||
|
}
|
|||
|
}
|