コード例 #1
0
        public async Task <ActionResult <IEnumerable <AzureAdGroupDto> > > GetGroups()
        {
            try
            {
                // Load groups profiles.
                var groupList = await _azureAdRepository.GetGroups();

                var groupListDto = _mapper.Map <IEnumerable <AzureAdGroupDto> >(groupList);
                foreach (var azureAdGroupDto in groupListDto)
                {
                    var groupExist = await _groupRepository.GroupExists(azureAdGroupDto.Id);

                    if (groupExist)
                    {
                        azureAdGroupDto.AddedToDb = true;
                    }
                }

                return(Ok(groupListDto));
            }
            catch (ServiceException ex)
            {
                if (ex.StatusCode == HttpStatusCode.BadRequest)
                {
                    return(BadRequest());
                }
                else
                {
                    return(NotFound());
                }
            }
        }
コード例 #2
0
        public async Task <ActionResult <IEnumerable <GroupDto> > > GetGroups()
        {
            var allGroupsFromRepo = await _groupRepository.GetGroups();

            var allGroupsFromAzureAd = await _azureAdRepository.GetGroups();

            var mergedGroups = DataMerger.MergeGroupsWithAzureData(allGroupsFromRepo,
                                                                   allGroupsFromAzureAd, _mapper);

            return(Ok(mergedGroups));
        }
コード例 #3
0
        public async Task <ActionResult <IEnumerable <GroupDto> > > GetSmartLockGroups(Guid smartLockId)
        {
            var smartLockExists = await _smartLockRepository.SmartLockExists(smartLockId);

            if (!smartLockExists)
            {
                return(NotFound());
            }

            var allSmartLockGroupsFromRepo = await _smartLockRepository.GetSmartLockGroups(smartLockId);

            var allGroupsFromAzureAd = await _azureAdRepository.GetGroups();

            var mergedSmartLockUsers = DataMerger.MergeGroupsWithAzureData(
                allSmartLockGroupsFromRepo, allGroupsFromAzureAd, _mapper);

            return(Ok(mergedSmartLockUsers));
        }