public Result <TOption, OperationError> Remove(TOwner owner, int optionId) { if (owner == null) { throw new ArgumentNullException(nameof(owner)); } return (_optionsService .GetOption(owner.OrganizationId, optionId) //Option may have been deprecated so allow it not to be available .Select(x => x.option) .Select(option => PerformRemove(owner, option)) .Match(result => result, () => new OperationError("Invalid option id", OperationFailure.BadInput))); }
public Result <DataProcessingRegistrationRight, OperationError> RemoveRole(DataProcessingRegistration registration, int roleId, int userId) { if (registration == null) { throw new ArgumentNullException(nameof(registration)); } var user = _userRepository.GetById(userId).FromNullable(); if (user.IsNone) { return(new OperationError($"User Id {userId} is invalid'", OperationFailure.BadInput)); } var role = _localRoleOptionsService.GetOption(registration.OrganizationId, roleId); if (role.IsNone) { return(new OperationError($"Role Id {roleId} is invalid'", OperationFailure.BadInput)); } return(registration.RemoveRole(role.Value.option, user.Value)); }