예제 #1
0
        public StationFeedback(RequiredInformation requiredInfo, JToken feedbackData)
        {
            var thumbsUpData = feedbackData["thumbsUp"];

            if (thumbsUpData != null)
            {
                ThumbsUp = from thumbUp in thumbsUpData select TrackFactory.CreateTrack(requiredInfo, thumbUp);
            }

            var thumbsDownData = feedbackData["thumbsDown"];

            if (thumbsDownData != null)
            {
                ThumbsDown = from thumbDown in thumbsDownData select TrackFactory.CreateTrack(requiredInfo, thumbDown);
            }
        }
예제 #2
0
        public void AddTrack(IAddTrackView inForm)
        {
            TrackRepository trackRepository = TrackRepository.GetInstance();

            if (inForm.ShowViewModal() == true)
            {
                try
                {
                    string Name = inForm.TrackName;
                    if (string.IsNullOrEmpty(Name))
                    {
                        throw new ArgumentException("Track name is not selected!");
                    }

                    string Location = inForm.TrackLocation;
                    if (string.IsNullOrEmpty(Location))
                    {
                        throw new ArgumentException("Location is not selected!");
                    }

                    int Length = inForm.TrackLength;

                    if (Length < 0)
                    {
                        throw new ArgumentException("Length value not supported!");
                    }

                    int ID = trackRepository.GetNewID();

                    Track newTrack = TrackFactory.CreateTrack(ID, Name, Location, Length);

                    trackRepository.AddTrack(newTrack);
                }
                catch (TrackAlreadyExistsException)
                {
                    MessageBox.Show("Track already exists!");
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
예제 #3
0
        private IEnumerable <ITrack> RetrievePlaylist(string stationToken)
        {
            var result = new List <ITrack>();

            try
            {
                var retrievePlaylistRequest = new JSONRequest(
                    MethodNames.station_getPlaylist,
                    false,
                    RequiredInfo,
                    new KeyValuePair <string, object>("stationToken", stationToken));
                var res = new JSONResult(retrievePlaylistRequest.StringRequestAsync().Result);

                if (res.IsFault)
                {
                    Messenger.Default.Send(new FaultMessage(res.Fault.Message));
                    return(null);
                }

                var data = res.Result;
                foreach (var item in data["items"])
                {
                    if (item["songName"] == null)
                    {
                        continue;
                    }

                    result.Add(TrackFactory.CreateTrack(RequiredInfo, item));
                }
            }
            catch (Exception ex)
            {
                Messenger.Default.Send(new FaultMessage(ex.Message, ex));
                return(null);
            }

            return(result);
        }
예제 #4
0
 public void CreateTrack_CreatesTrackWithTag_TagIsCorrect(string trackInfo, string expectedTag)
 {
     Assert.That(_uut.CreateTrack(trackInfo).Tag, Is.EqualTo(expectedTag));
 }