public async Task <SecurableItem> GetSecurableItem(string clientId, Guid itemId) { try { var topLevelSecurableItem = await GetTopLevelSecurableItem(clientId); return(GetSecurableItemById(topLevelSecurableItem, itemId)); } catch (NotFoundException <SecurableItem> ) { var securableItem = await _securableItemStore.Get(itemId); if (await _clientService.DoesClientOwnItem(clientId, securableItem.Grain, securableItem.Name)) { return(securableItem); } } throw new NotFoundException <SecurableItem>(itemId.ToString()); }
/// <summary> /// Gets all roles owned by the specified <paramref name="client"/>. /// </summary> /// <param name="client"></param> /// <returns></returns> public async Task <IEnumerable <Role> > GetRoles(Client client) { var clientRoles = new List <Role>(); var roles = await GetRoles(); foreach (var role in roles) { try { if (await _clientService.DoesClientOwnItem(client.Id, role.Grain, role.SecurableItem)) { clientRoles.Add(role); } } catch (NotFoundException <SecurableItem> ) { } } return(clientRoles); }