public void Execute(ReRouteDocumentCommand command)
        {
            try
            {
                var commands = _commandRoutingOnRequestRepository.GetByParentDocumentId(command.DocumentId);
                foreach (var commandRouteOnRequest in commands)
                {
                    var routeCentre =
                        _commandRoutingOnRequestRepository.GetByRouteCentreByIdAndCostcentreId(
                            commandRouteOnRequest.Id, command.ReciepientCostCentreId);
                    if (routeCentre == null)
                    {
                        routeCentre = new CommandRouteOnRequestCostcentre();
                        routeCentre.CostCentreId = command.ReciepientCostCentreId;
                        routeCentre.CommandRouteOnRequestId = commandRouteOnRequest.Id;
                        routeCentre.CommandType = commandRouteOnRequest.CommandType;
                        routeCentre.DateAdded = DateTime.Now;
                        routeCentre.IsRetired = commandRouteOnRequest.IsRetired;
                        routeCentre.IsValid = true;
                        _commandRoutingOnRequestRepository.AddRoutingCentre(routeCentre);
                    }


                }
                _commandProcessingAuditRepository.SetCommandStatus(command.CommandId, CommandProcessingStatus.Complete);
            }catch(Exception ex)
            {
                _commandProcessingAuditRepository.SetCommandStatus(command.CommandId, CommandProcessingStatus.MarkedForRetry);
            }
        }
 public void AddRoutingCentre(CommandRouteOnRequestCostcentre commandRouteOnRequestCostcentre)
 {
     commandRouteOnRequestCostcentre.IsValid = true;
     commandRouteOnRequestCostcentre.DateAdded = DateTime.Now;
     _CommandRouteOnRequestCostcentreCollection.Save(commandRouteOnRequestCostcentre);
 }