コード例 #1
0
        public async Task <SubRealm> GetByIdAsync(Guid subRealmId)
        {
            SubRealmModel existingSubRealm = await subRealmRepository.GetByIdAsync(subRealmId, true);

            if (existingSubRealm == null)
            {
                throw new ItemNotFoundException($"Sub-Realm with ID '{subRealmId}' not found.");
            }

            return(mapper.Map <SubRealm>(existingSubRealm));
        }
コード例 #2
0
        private async Task CheckForSubRealmAndAssignToFunctionIfExists(FunctionModel function, FunctionSubmit functionSubmit)
        {
            // Recall that submit models with empty GUIDs will not be null but rather Guid.Empty.
            if (functionSubmit.SubRealmId == null || functionSubmit.SubRealmId == Guid.Empty)
            {
                return;
            }

            var existingSubRealm = await subRealmRepository.GetByIdAsync(functionSubmit.SubRealmId, false);

            function.SubRealm = existingSubRealm ?? throw new ItemNotFoundException($"Sub-realm with ID '{functionSubmit.SubRealmId}' does not exist.");
        }
コード例 #3
0
        private async Task CheckForSubRealmAndAssignToProfileIfExists(ProfileModel profile, UserProfileSubmit userProfileSubmit)
        {
            // Recall that submit models with empty GUIDs will not be null but rather Guid.Empty.
            if (userProfileSubmit.SubRealmId == null || userProfileSubmit.SubRealmId == Guid.Empty)
            {
                throw new InvalidFormatException("Profiles must contain a 'sub_realm_id'.");
            }

            var existingSubRealm = await subRealmRepository.GetByIdAsync(userProfileSubmit.SubRealmId, false);

            profile.SubRealm = existingSubRealm ?? throw new ItemNotFoundException($"Sub-realm with ID '{userProfileSubmit.SubRealmId}' does not exist.");
        }
コード例 #4
0
        private async Task CheckForSubRealmAndAssignToRoleIfExists(RoleModel role, RoleSubmit roleSubmit)
        {
            // Recall that submit models with empty GUIDs will not be null but rather Guid.Empty.
            if (roleSubmit.SubRealmId == null || roleSubmit.SubRealmId == Guid.Empty)
            {
                return;
            }

            var existingSubRealm = await subRealmRepository.GetByIdAsync(roleSubmit.SubRealmId, false);

            role.SubRealm = existingSubRealm ?? throw new ItemNotFoundException($"Sub-realm with ID '{roleSubmit.SubRealmId}' does not exist.");
        }