37 lines
981 B
C#
37 lines
981 B
C#
using BeautySaloonContracts.BindingModels;
|
|
using BeautySaloonContracts.ViewModels;
|
|
using BeautySaloonDataModels;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace BeautySaloonDatabaseImplement.Models
|
|
{
|
|
public class Position : IPositionModel
|
|
{
|
|
public int Id { get; set; }
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
[ForeignKey("PositionId")]
|
|
public virtual List<Employee> Employees { get; set; } = new();
|
|
|
|
public static Position Create(PositionBindingModel model)
|
|
{
|
|
return new Position()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name
|
|
};
|
|
}
|
|
public void Update(PositionBindingModel model)
|
|
{
|
|
Name = model.Name;
|
|
}
|
|
|
|
public PositionViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name
|
|
};
|
|
}
|
|
}
|