public void Execute() { var newServiceComponent = new ServiceComponent { ServiceFunctionId = _serviceFunction.Id, ServiceFunction = _serviceFunction, ComponentName = _serviceComponent.ComponentName, ComponentLevel = _serviceComponent.ComponentLevel, ServiceActivities = _serviceComponent.ServiceActivities, ChildServiceComponents = new List <ServiceComponent>(), InsertedBy = _serviceComponent.InsertedBy, InsertedDate = _serviceComponent.InsertedDate, UpdatedBy = _serviceComponent.UpdatedBy, UpdatedDate = _serviceComponent.UpdatedDate }; _serviceFunction.ServiceComponents.Add(newServiceComponent); _unitOfWork.Save(); if (_serviceComponent.Resolver != null) { var serviceComponentResolverProcessor = new ServiceComponentResolverProcessor(_serviceDesk, _serviceComponent, newServiceComponent, _dataContext, _unitOfWork); serviceComponentResolverProcessor.Execute(); } else if (_serviceComponent.ChildServiceComponents != null && _serviceComponent.ChildServiceComponents.Any()) { var childServiceComponentProcessor = new ChildServiceComponentProcessor(_serviceDesk, _serviceFunction, newServiceComponent, _serviceComponent.ChildServiceComponents, _dataContext, _unitOfWork); childServiceComponentProcessor.Execute(); } }
public void Execute() { foreach (var childServiceComponent in _childServiceComponents) { var newServiceComponent = new ServiceComponent { ServiceFunctionId = _serviceFunction.Id, ServiceFunction = _serviceFunction, ParentServiceComponent = _parentServiceComponent, ParentServiceComponentId = _parentServiceComponent.Id, ComponentName = childServiceComponent.ComponentName, ComponentLevel = childServiceComponent.ComponentLevel, ServiceActivities = childServiceComponent.ServiceActivities, InsertedBy = childServiceComponent.InsertedBy, InsertedDate = childServiceComponent.InsertedDate, UpdatedBy = childServiceComponent.UpdatedBy, UpdatedDate = childServiceComponent.UpdatedDate }; _parentServiceComponent.ChildServiceComponents.Add(newServiceComponent); _unitOfWork.Save(); if (childServiceComponent.Resolver != null) { var serviceComponentResolverProcessor = new ServiceComponentResolverProcessor(_serviceDesk, childServiceComponent, newServiceComponent, _dataContext, _unitOfWork); serviceComponentResolverProcessor.Execute(); } } }