PIbd-33_Nevaeva_KA_COP_28/NevaevaLibrary/AccountDatabaseImplement/Models/Role.cs
2023-12-01 01:01:22 +04:00

56 lines
1.3 KiB
C#

using AccountContracts.BindingModels;
using AccountContracts.ViewModels;
using AccountsDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountDatabaseImplement.Models
{
public class Role : IRoleModel
{
public int Id { get; private set; }
[Required]
public string RoleName { get; private set; } = string.Empty;
public static Role? Create(RoleBindingModel model)
{
if (model == null)
{
return null;
}
return new Role()
{
Id = model.Id,
RoleName = model.RoleName,
};
}
public static Role Create(RoleViewModel model)
{
return new Role
{
Id = model.Id,
RoleName = model.RoleName,
};
}
public void Update(RoleBindingModel model)
{
if (model == null)
{
return;
}
RoleName = model.RoleName;
}
public RoleViewModel GetViewModel => new()
{
Id = Id,
RoleName = RoleName,
};
}
}