コード例 #1
0
        public HttpResponseMessage Song(Song song)
        {
            // Check if the queue contains a song with the same Id. If it does we return with NotModified
            if (_queueService.CurrentQueue.Any(i =>
            {
                if (i.Bag is Song)
                {
                    return i.Bag.Id == song.Id;
                }

                return false;
            }))
            {
                return new HttpResponseMessage(HttpStatusCode.NotModified);
            }

            var stream = new SingleSongStream(song)
            {
                Name = song.Name, Description = song.Artist.Name
            };

            _queueService.Enqueue(stream, setup =>
            {
                setup.Bag = song;
            });

            return Request.CreateResponse(HttpStatusCode.OK);
        }