public async Task <Boolean> Handle(UpdateDHCPv4ScopeParentCommand request, CancellationToken cancellationToken) { _logger.LogDebug("Handle started"); var scope = _rootScope.GetScopeById(request.ScopeId); if (scope == DHCPv4Scope.NotFound) { return(false); } if (request.ParentScopeId.HasValue == true) { if (_rootScope.GetScopeById(request.ParentScopeId.Value) == DHCPv4Scope.NotFound) { return(false); } } Boolean moveResult = _rootScope.UpdateParent(request.ScopeId, request.ParentScopeId); if (moveResult == true) { Boolean result = await _store.Save(_rootScope); return(result); } return(false); }
public async Task <Boolean> Handle(UpdateDHCPv4ScopeCommand request, CancellationToken cancellationToken) { _logger.LogDebug("Handle started"); var scope = _rootScope.GetScopeById(request.ScopeId); if (scope == DHCPv4Scope.NotFound) { return(false); } Guid?parentId = scope.HasParentScope() == false ? new Guid?() : scope.ParentScope.Id; var properties = GetScopeProperties(request); var addressProperties = GetScopeAddressProperties(request); if (request.Name != scope.Name) { _rootScope.UpdateScopeName(request.ScopeId, ScopeName.FromString(request.Name)); } if (request.Description != scope.Description) { _rootScope.UpdateScopeDescription(request.ScopeId, ScopeDescription.FromString(request.Description)); } if (request.ParentId != parentId) { _rootScope.UpdateParent(request.ScopeId, request.ParentId); } _rootScope.UpdateScopeResolver(request.ScopeId, GetResolverInformation(request)); if (addressProperties != scope.AddressRelatedProperties) { _rootScope.UpdateAddressProperties(request.ScopeId, addressProperties); } if (properties != scope.Properties) { _rootScope.UpdateScopeProperties(request.ScopeId, properties); } Boolean result = await _store.Save(_rootScope); if (result == true) { var triggers = _rootScope.GetTriggers(); if (triggers.Any() == true) { await _serviceBus.Publish(new NewTriggerHappendMessage(triggers)); _rootScope.ClearTriggers(); } } return(result); }