56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using ElectronicsShopContracts.BindingModels;
|
|
using ElectronicsShopContracts.ViewModels;
|
|
using ElectronicsShopDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ElectronicsShopDataBaseImplement.Models
|
|
{
|
|
public class Role : IRoleModel
|
|
{
|
|
public int ID { get; set; }
|
|
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
public static Role? Create(RoleBindingModel? model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Role()
|
|
{
|
|
ID = model.ID,
|
|
Name = model.Name
|
|
};
|
|
}
|
|
public static Role? Create(RoleViewModel model)
|
|
{
|
|
return new Role
|
|
{
|
|
ID = model.ID,
|
|
Name = model.Name
|
|
};
|
|
}
|
|
public void Update(RoleBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
Name = model.Name;
|
|
}
|
|
|
|
public RoleViewModel GetViewModel => new()
|
|
{
|
|
ID = ID,
|
|
Name = Name
|
|
};
|
|
}
|
|
}
|