public override void Execute(IEvent receivedEvent) { if (receivedEvent == null) { throw new ArgumentNullException(nameof(receivedEvent)); } if (!(receivedEvent.Data is JObject payload)) { _logger.Debug("there was no payload in the request"); return; } var queueType = (string)payload["queue"]; var data = (JArray)payload["data"]; var play = (string)payload["play"]; if (data == null) { const int code = 400; SendResponse(receivedEvent.ConnectionId, code); return; } var queue = QueueType.PlayNow; if (queueType.Equals("next", StringComparison.InvariantCultureIgnoreCase)) { queue = QueueType.Next; } else if (queueType.Equals("last", StringComparison.InvariantCultureIgnoreCase)) { queue = QueueType.Last; } else if (queueType.Equals("add-all", StringComparison.InvariantCultureIgnoreCase)) { queue = QueueType.AddAndPlay; } var success = _queueAdapter.QueueFiles(queue, data.Select(c => (string)c).ToArray(), play); SendResponse(receivedEvent.ConnectionId, success ? 200 : 500); }
public override void Execute(IEvent @event) { var payload = @event.Data as JObject; if (payload == null) { Logger.Debug("there was no payload in the request"); return; } var queueType = (string)payload["queue"]; var data = (JArray)payload["data"]; var play = (string)payload["play"]; if (data == null) { const int code = 400; SendResponse(@event.ConnectionId, code); return; } var queue = QueueType.PlayNow; if (queueType.Equals("next")) { queue = QueueType.Next; } else if (queueType.Equals("last")) { queue = QueueType.Last; } else if (queueType.Equals("add-all")) { queue = QueueType.AddAndPlay; } var success = _queueAdapter.QueueFiles(queue, data.Select(c => (string)c).ToArray(), play); SendResponse(@event.ConnectionId, success ? 200 : 500); }