public Registration(Robot robot, RobotImported e, Guid endUserId)
 {
     Id          = new RobotRegistrationId(Guid.NewGuid());
     EndUserId   = new EndUserId(endUserId);
     Name        = $"{robot.Product:G} - {robot.SerialNumber}";
     Application = e.Entity.GetRobotApplication();
 }
示例#2
0
        public static Robot Import(RobotImported.RobotEntity entity)
        {
            var id    = new RobotId(entity.C2RurRobotsid);
            var e     = RobotImported.Create(entity);
            var robot = new Robot(id, e);

            robot.Append(id.Value, RobotImported.EventType, e);
            return(robot);
        }
示例#3
0
        private Robot(RobotId id, RobotImported e)
            : base(id)
        {
            SerialNumber = new SerialNumber(e.Entity.C2RurName);
            Product      = e.Entity.RobotProduct();

            Registrations = ImmutableList <RobotRegistration> .Empty;
            ImportRegistrations(e);
        }
示例#4
0
        private void ImportRegistrations(RobotImported e)
        {
            void AddRegistration(Guid endUserId)
            {
                var newRegistration = new RobotRegistration.Registration(this, e, endUserId);

                Registrations = Registrations.Add(newRegistration);
            }

            var latestRegistration = Registrations.LastOrDefault();

            if (latestRegistration == null)
            {
                if (e.Entity.C2RurEnduserValue != null)
                {
                    AddRegistration(e.Entity.C2RurEnduserValue.Value);
                }
            }
            else
            {
                latestRegistration.Apply(
                    registration =>
                {
                    if (registration.EndUserId.Value == e.Entity.C2RurEnduserValue)
                    {
                        registration.Apply(e);
                    }
                    else if (e.Entity.C2RurEnduserValue.HasValue)
                    {
                        AddRegistration(e.Entity.C2RurEnduserValue.Value);
                    }
                    else
                    {
                        Registrations = Registrations.Add(RobotRegistration.Unregistration.Instance);
                    }
                },
                    unregistration =>
                {
                    if (e.Entity.C2RurEnduserValue.HasValue)
                    {
                        AddRegistration(e.Entity.C2RurEnduserValue.Value);
                    }
                }
                    );
            }
        }
示例#5
0
 private void Apply(RobotImported e)
 {
     SerialNumber = new SerialNumber(e.Entity.C2RurName);
     ImportRegistrations(e);
 }
 public void Apply(RobotImported e)
 {
     Application = e.Entity.AkaApplicationTest?.GetRobotApplication();
 }