Exemplo n.º 1
0
        public void Handle(RegisterLogicalService message)
        {
            var service = session.Load <ServiceStructure>(message.ServiceId.ToString());

            if (service == null)
            {
                service = new ServiceStructure {
                    Id = message.ServiceId.ToString()
                }
            }
            ;

            service.Name = message.ServiceName;

            session.Store(service);
        }
    }
        public void Handle(RegisterAutonomousComponent message)
        {
            var service = session.Load <ServiceStructure>(message.ServiceId.ToString());

            if (service == null)
            {
                service = new ServiceStructure {
                    Id = message.ServiceId.ToString()
                }
            }
            ;

            if (service.AutonomousComponents == null)
            {
                service.AutonomousComponents = new List <AutonomousComponent>();
            }


            var existingAc = service.AutonomousComponents.SingleOrDefault(ac => ac.Id == message.AutonomousComponentId);

            if (existingAc == null)
            {
                service.AutonomousComponents.Add(new AutonomousComponent
                {
                    Id       = message.AutonomousComponentId,
                    Name     = message.AutonomousComponentName,
                    Versions = new List <string> {
                        message.Version
                    }
                });
            }
            else
            {
                if (existingAc.Versions == null)
                {
                    existingAc.Versions = new List <string>();
                }

                if (!existingAc.Versions.Contains(message.Version))
                {
                    existingAc.Versions.Add(message.Version);
                }
            }
            session.Store(service);
        }
    }