public bool CheckUserPermissionToSubscription(string subscriptionId) { var repository = new TableCoreRepository(); var subscription = repository.GetSubscription(subscriptionId); var currentUsersGroups = Utils.GetCurrentUserGroups(); var contributorGroups = JArray.Parse(subscription.ContributorGroups); var ids = contributorGroups.Select(x => (string)x["id"]).ToList(); return(currentUsersGroups.Intersect(ids).Count() > 0); }
private async Task <dynamic> UpdateAscContributorRole(string subscriptionId) { dynamic role = null; var coreRepository = new TableCoreRepository(); var dbSubscriptions = coreRepository.GetSubscriptionListByOrgId(ClaimsPrincipal.Current.TenantId()); //Check in the subscriptions other than the current one for the Asc Contributor role List <string> subscriptionList = dbSubscriptions?.Where(s => s.Id != subscriptionId)?.Select(s => s.Id)?.ToList(); if (subscriptionList != null && subscriptionList.Count > 0) { var existingRole = await rbacClient.GetAscContributorRole(subscriptionList); var roleResult = await rbacClient.UpdateAscContributorRoleOnSubscription(subscriptionId, existingRole); role = JObject.Parse(roleResult); } return(role); }