public void Handle(ChangeNetworkDeviceHostName message)
 {
     try
     {
         NetworkDevice device = _session.Get <NetworkDevice>(message.Id);
         device.SetHostname(message.NewHostname);
         _session.Commit(message.CommandId);
         SendNotification(message, true, "Network device updated successfully.");
     }
     catch (Exception ex)
     {
         SendNotification(message, false, "Could not change hostname", ex);
     }
 }
 public void Handle(NetworkDeviceSetStatus message)
 {
     try
     {
         NetworkDevice device = _session.Get <NetworkDevice>(message.Id);
         device.IsOnline(message.IsOnline);
         _session.Commit(message.CommandId);
         SendNotification(message, true, "Network device updated successfully");
     }
     catch (Exception ex)
     {
         SendNotification(message, false, "Could not set online status", ex);
     }
 }
        public void Handle(CreateNetworkDevice message)
        {
            try
            {
                if (_session.Any <NetworkDevice>(message.Id))
                {
                    throw new AggregateException("Networkdevice already exists");
                }

                var device = new NetworkDevice(message.Id, message.Hostname);
                _session.Add(device);
                _session.Commit(message.CommandId);

                SendNotification(message, true, "Network device created successfully.");
            }
            catch (Exception ex)
            {
                SendNotification(message, false, "Could not add network device", ex);
            }
        }