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, }; } }