public RoleNode(Role role) { Role = role; Roles = new ObservableCollection<RoleNode>(); Activities= new ObservableCollection<ActivityNode>(); }
public async Task<Role> SaveRole(Role role) { var json = Serializer.SerializeToJson(role); var response = await authorisationManagerService.SaveRole(json).ConfigureAwait(false); role = ServiceResponse.Deserialize<Role>(response); return role; }
public Role SaveRole(Role role) { return authorisationManagerServiceData.SaveRole(role); }
private static bool CanPerformActivityCheck(Role role, string activityCode) { if (role.Activities.Any(a => a.ActivityCode.ToUpper().Equals(activityCode.ToUpper()))) { return true; } foreach (var activity in role.Activities) { if (CanPerformActivityCheck(activity, activityCode)) { return true; } } foreach (var child in role.Roles) { if (CanPerformActivityCheck(child, activityCode)) { return true; } } return false; }
private static bool IsInRoleCheck(Role role, string roleCode) { if (role.Roles.Any(r => r.RoleCode.ToUpper().Equals(roleCode.ToUpper()))) { return true; } foreach (var child in role.Roles) { if (IsInRoleCheck(child, roleCode)) { return true; } } return false; }
public Role SaveRole(Role role) { var isInsert = role.Id.Equals(0); using (var conn = new SqlConnection(ConnectionString)) { if (isInsert) { role = conn.Insert(role, "Id"); } else { conn.Update(role, new Dictionary<string, object>() {{"Id", role.Id}}, new[] {"Id"}); } } return role; }
private RoleNode GetRoleNode(Role role) { var roleNode = new RoleNode(role); role.Activities.ToList().ForEach(a => { var an = GetActivityNode(a); an.ParentId = role.Id; an.ParentType = ParentType.RoleNode; roleNode.Activities.Add(an); }); role.Roles.ToList().ForEach(r => { var rn = GetRoleNode(r); rn.ParentId = role.Id; rn.ParentType = ParentType.RoleNode; roleNode.Roles.Add(rn); }); return roleNode; }