Exemplo n.º 1
0
        // GET: api/Songs/{id}
        public SongsModel GetSongById(string id)
        {
            SongsModel selSong = null;

            //grabs song based on passed id
            using (var ctx = new Assignment2Entities())
            {
                selSong = ctx.songs
                          .Where(s => (s.id).ToString() == id)
                          .Select(s => new SongsModel()
                {
                    sId   = s.id,
                    sName = s.songName,
                    aName = s.artistName,
                    year  = s.yearPublished,
                }).FirstOrDefault <SongsModel>();
            }

            //return null if no song found
            if (selSong == null)
            {
                return(null);
            }

            return(selSong);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Called when [update artist button clicked].
 /// </summary>
 private void OnAddArtistButtonClicked()
 {
     sm            = new SongsModel();
     sm.ArtistName = sdb.GetRandomArtistName;
     sm.SongTitle  = sdb.GetRandomSongTitle;
     _songs.Add(sm);
 }
Exemplo n.º 3
0
        public async Task <SongsModel> GetListSongsBasedCategory(string category)
        {
            var    list      = new SongsModel();
            string url       = "/v1/playlists/{0}/tracks";
            var    playLists = await _categoryModule.GetPlayLists(category);

            var httpClient = await _authenticationModule.GetHttpClient();

            foreach (var playlist in playLists)
            {
                string urlFormatted = String.Format(url, playlist.Id);
                var    response     = await httpClient.GetAsync(urlFormatted);

                if (response.IsSuccessStatusCode)
                {
                    var json = await response.Content.ReadAsStringAsync();

                    var tracks = JsonConvert.DeserializeObject <TracksModel>(json);
                    foreach (var track in tracks.Items)
                    {
                        list.Songs.Add(new SongReducedModel
                        {
                            SongId    = track.Track.Id,
                            SongTitle = track.Track.Name
                        });
                    }
                }
            }

            return(list);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ISongObservable songModel      = new SongsModel();
            ISongController songController = new MainController(songModel);
            IViewComponent  mainView       = new MainMenuView(songController);

            mainView.Display();
        }
Exemplo n.º 5
0
 public SongsViewModel(SongsModel songsModel)
 {
     SongsModel           = songsModel;
     collectionViewSource = new CollectionViewSource {
         Source = SongsModel.Songs
     };
     collectionViewSource.View.Filter = (o) => FilterSong((Song)o);
     Songs = collectionViewSource.View;
 }
Exemplo n.º 6
0
 public ActionResult Index()
 {
     using (var context = new DbMifEF())
     {
         SongsModel model = new SongsModel();
         model.Songs = context.Songs.ToList();
         WriteToLog();
         return(View(model));
     }
 }
Exemplo n.º 7
0
        public void Verify_ISong_Details_Match_Song_Name()
        {
            //Arrange
            SongsRepo sr        = new SongsRepo();
            string    exp_sname = "TestSong";

            //Act
            SongsModel smd    = sr.GetSong(5);
            string     s_name = smd.S_name;

            //Assert
            Assert.AreEqual(exp_sname, s_name);
        }
Exemplo n.º 8
0
 public ActionResult AddSong(SongsModel model)
 {
     if (ModelState.IsValid)
     {
         int id = srep.AddSong(model);
         if (id > 0)
         {
             ModelState.Clear();
             ViewBag.IsSuccess = "Song Added.";
         }
     }
     return(View());
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SongsViewModel"/> class.
 /// </summary>
 public SongsViewModel()
 {
     sdb    = new SongsDataBase();
     _songs = new ObservableCollection <SongsModel>();
     //Initializing some data
     for (int i = 0; i < 5; i++)
     {
         sm            = new SongsModel();
         sm.ArtistName = sdb.GetRandomArtistName;
         sm.SongTitle  = sdb.GetRandomSongTitle;
         _songs.Add(sm);
     }
 }
Exemplo n.º 10
0
        public void Verify_Edit_song()
        {
            //Arrange
            AdminController controllerUnderTest = new AdminController();
            SongsRepo       ur    = new SongsRepo();
            var             model = new SongsModel();
            //Act


            var result = controllerUnderTest.EditSong(2, model) as ViewResult;

            // Assert
            Assert.AreEqual(2, result);
        }
Exemplo n.º 11
0
        public void Verify_Delete_song()
        {
            //Arrange
            AdminController controllerUnderTest = new AdminController();
            SongsRepo       ur    = new SongsRepo();
            var             model = new SongsModel();
            //Act


            var result = controllerUnderTest.DeleteSong(3) as ViewResult;

            // Assert
            Assert.AreEqual("ManageSongs", result);
        }
Exemplo n.º 12
0
        //Edit Songs Details
        public ActionResult EditSong(int id, SongsModel model)
        {
            if (ModelState.IsValid)
            {
                int idd = srep.EditSong(model);
                if (idd > 0)
                {
                    ViewBag.IsSuccess = "Song details updated!";
                }
            }
            SongsRepo sr = new SongsRepo();

            return(View(sr.GetSong(id)));
        }
Exemplo n.º 13
0
 public SongViewModel(SongsModel songsModel, Song song)
 {
     SongsModel = songsModel;
     Song       = song;
     if (Song != null)
     {
         Title       = Song.Title;
         Author      = Song.Author;
         ReleaseDate = Song.ReleaseDate;
         Category    = Song.Category;
     }
     else
     {
         ReleaseDate = DateTime.Now;
     }
 }
Exemplo n.º 14
0
        //Edit Song
        public int EditSong(SongsModel model)
        {
            using (var context = new MusicDBEntities())
            {
                var sg = context.Songs.Where(x => x.Id == model.Id).FirstOrDefault();

                sg.S_name     = model.S_name;
                sg.R_date     = model.R_date;
                sg.Art_name   = model.Art_name;
                sg.Genre      = model.Genre;
                sg.Album_name = model.Album_name;
                sg.Song_link  = model.Song_link;

                context.SaveChanges();

                return(sg.Id);
            }
        }
Exemplo n.º 15
0
        //Add Song
        public int AddSong(SongsModel model)
        {
            using (var context = new MusicDBEntities())
            {
                Songs sg = new Songs()
                {
                    S_name     = model.S_name,
                    R_date     = model.R_date,
                    Art_name   = model.Art_name,
                    Genre      = model.Genre,
                    Album_name = model.Album_name,
                    Song_link  = model.Song_link
                };
                context.Songs.Add(sg);

                context.SaveChanges();

                return(sg.Id);
            }
        }
Exemplo n.º 16
0
        //get song
        public SongsModel GetSong(int id)
        {
            using (var context = new MusicDBEntities())
            {
                Songs s = context.Songs.Where(x => x.Id == id).FirstOrDefault();

                SongsModel sm = new SongsModel()
                {
                    Id         = s.Id,
                    S_name     = s.S_name,
                    R_date     = s.R_date,
                    Art_name   = s.Art_name,
                    Genre      = s.Genre,
                    Album_name = s.Album_name,
                    Song_link  = s.Song_link
                };

                return(sm);
            }
        }
Exemplo n.º 17
0
        public int AddSong(SongsModel model)
        {
            using (var context = new MusicDBEntities())
            {
                Songs sg = new Songs()
                {
                    image      = model.image,
                    s_name     = model.s_name,
                    r_date     = model.r_date,
                    art_name   = model.art_name,
                    genre      = model.genre,
                    album_name = model.album_name,
                    song_link  = model.song_link
                };

                context.Songs.Add(sg);

                context.SaveChanges();

                return(sg.sid);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// uses the Get mehod to retreive information from an API
        /// </summary>
        /// <param name="table"> the table who's API is being called</param>
        private static void getAPICall(string table)
        {
            Console.WriteLine("");
            Console.WriteLine("Which " + table + " do you wish to view?");
            Console.WriteLine("(enter '0' to view all)");
            string choice = Console.ReadLine();

            if (table.Equals("songs"))
            {
                SongsController cont = new SongsController();
                if (choice.Equals("0"))
                {
                    List <SongsModel> songs = cont.GetAllSongs();
                    foreach (SongsModel song in songs)
                    {
                        Console.WriteLine("");
                        Console.WriteLine(song.sId);
                        Console.WriteLine(song.sName);
                        Console.WriteLine(song.aName);
                        Console.WriteLine(song.year);
                    }
                }
                else
                {
                    SongsModel song = cont.GetSongById(choice);
                    if (song != null)
                    {
                        Console.WriteLine("");
                        Console.WriteLine(song.sId);
                        Console.WriteLine(song.sName);
                        Console.WriteLine(song.aName);
                        Console.WriteLine(song.year);
                    }
                    else
                    {
                        Console.WriteLine("");
                        Console.WriteLine("Not Found.");
                    }
                }
            }
            else if (table.Equals("reviews"))
            {
                ReviewsController cont = new ReviewsController();
                if (choice.Equals("0"))
                {
                    List <ReviewsModel> revs = cont.GetAllReviews();
                    foreach (ReviewsModel rev in revs)
                    {
                        Console.WriteLine("");
                        Console.WriteLine(rev.rId);
                        Console.WriteLine(rev.sId);
                        Console.WriteLine(rev.sRating);
                        Console.WriteLine(rev.textReview);
                    }
                }
                else
                {
                    ReviewsModel rev = cont.GetReviewById(choice);

                    if (rev != null)
                    {
                        Console.WriteLine("");
                        Console.WriteLine(rev.rId);
                        Console.WriteLine(rev.sId);
                        Console.WriteLine(rev.sRating);
                        Console.WriteLine(rev.textReview);
                    }
                    else
                    {
                        Console.WriteLine("");
                        Console.WriteLine("Not Found.");
                    }
                }
            }
        }