/// <summary> /// Deletes a Role /// Level: Logic /// </summary> /// <param name="RoleID">The RoleID</param> /// <returns>RoleDeleteEnum</returns> public RoleDelete DeleteRole(int RoleID) { try { RolesRepository myRepository = new RolesRepository(); if (myRepository.RoleIsAdministratorOrUser(RoleID)) { return RoleDelete.LockedRole; } else if (myRepository.RoleHasUsers(RoleID)) { return RoleDelete.HasUsers; } else { myRepository.DeleteRole(RoleID); return RoleDelete.Successful; } } catch (Exception Exception) { throw Exception; } }
/// <summary> /// Updates a Role /// Level: Logic /// </summary> /// <param name="RoleID">The Role ID</param> /// <param name="Role">The Role</param> /// <returns>RoleUpdate Enum</returns> public RoleUpdate UpdateRole(int RoleID, string Role) { try { RolesRepository myRepository = new RolesRepository(); if (myRepository.RoleIsAdministratorOrUser(RoleID)) { return RoleUpdate.LockedRole; } else if (myRepository.RoleExists(Role)) { return RoleUpdate.SameRole; } else { myRepository.UpdateRole(RoleID, Role); return RoleUpdate.Successful; } } catch (Exception Exception) { throw Exception; } }