public bool checkIsAdminCommunity(string pShortName, Guid pUserID) { bool esAdmin = false; UserCommunityModel model = new UserCommunityModel(); model.community_short_name = pShortName; model.user_id = pUserID; string url = $"{ApiUrl}/community/check-administrator-community"; string response = WebRequestPostWithJsonObject(url, model); esAdmin = JsonConvert.DeserializeObject <bool>(response); return(esAdmin); }
/// <summary> /// Blocks a member in a community /// </summary> /// <param name="userId">User's identifier</param> /// <param name="communityShortName">Community short name</param> public void BlockMember(Guid userId) { try { UserCommunityModel parameters = new UserCommunityModel() { user_id = userId, community_short_name = CommunityShortName }; string url = $"{ApiUrl}/community/block-member"; WebRequestPostWithJsonObject(url, parameters); } catch (System.Exception) { Log.Error($"The user {userId} of the community members '{CommunityShortName}' could not be blocked"); throw; } }
/// <summary> /// Expel a user from a community /// </summary> /// <param name="userId">User identifier to expel from the community</param> public void ExpelMember(Guid userId) { try { string url = $"{ApiUrl}/community/expel-member"; UserCommunityModel model = new UserCommunityModel() { community_short_name = CommunityShortName, user_id = userId }; WebRequestPostWithJsonObject(url, model); Log.Debug($"User {userId} expelled from {CommunityShortName}"); } catch (Exception ex) { Log.Error($"Error expelling member {userId} from {CommunityShortName}: {ex.Message}"); throw; } }
/// <summary> /// Upgrade a user changing is role to community administrator /// </summary> /// <param name="userId">User identifier that we will upgrade to community</param> public void UpgradeMemberToAdministrator(Guid userId) { try { string url = $"{ApiUrl}/community/add-administrator-member"; UserCommunityModel model = new UserCommunityModel() { community_short_name = CommunityShortName, user_id = userId }; WebRequestPostWithJsonObject(url, model); Log.Debug($"The member {userId} has been upgraded to administrator of {CommunityShortName}"); } catch (Exception ex) { Log.Error($"Error upgrading member {userId} to administrator in {CommunityShortName}: {ex.Message}"); throw; } }