47 lines
929 B
C#
47 lines
929 B
C#
using Contracts.BindingModels;
|
|
using Contracts.ViewModels;
|
|
using DataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DatabaseImplement.Models
|
|
{
|
|
public class Role : IRole
|
|
{
|
|
public Guid Id { get; set; }
|
|
|
|
[Required]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
public RoleBindingModel GetBindingModel() => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
};
|
|
|
|
public static Role ToRoleFromView(RoleViewModel model) => new()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
};
|
|
|
|
public static Role ToRoleFromBinding(RoleBindingModel model) => new()
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
};
|
|
|
|
public void Update(RoleBindingModel model)
|
|
{
|
|
if (model is null)
|
|
{
|
|
throw new ArgumentNullException("Update role: bindinng model is null");
|
|
}
|
|
Name = model.Name;
|
|
}
|
|
}
|
|
} |