// GET: PlaylistController/Details/5
        public ActionResult Details(Guid id)
        {
            Playlist playlist = _playlistRepo.Get(id);

            if (playlist.ApplicationUserId != this.User.GetUserId())
            {
                return(Unauthorized());
            }
            return(RedirectToAction("Index", "Music", new { playlistId = id }));
        }
Example #2
0
        public void GetOnePlaylist()
        {
            var options = new DbContextOptionsBuilder <BetterCalmContext>()
                          .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options;
            var context = new BetterCalmContext(options);

            listPlaylist.ForEach(cat => context.Add(cat));
            context.SaveChanges();
            repository = new PlaylistRepository(context);
            var playlist = repository.Get(listPlaylist[0].Id);

            context.Database.EnsureDeleted();
            Assert.AreEqual(listPlaylist[0].Id, playlist.Id);
        }
        public ActionResult Index(Guid playlistId)
        {
            Playlist playlist = _playlistRepo.Get(playlistId);

            if (playlist.ApplicationUserId != this.User.GetUserId())
            {
                return(Unauthorized());
            }
            ViewBag.playlistId   = playlistId;
            ViewBag.playlistName = _playlistRepo.Get(playlistId).PlaylistName;
            List <Music> musics = _musicRepo.GetAllFromPlaylist(playlistId);

            return(View(musics));
        }
Example #4
0
        public void DeleteOnePlaylist()
        {
            Playlist playlistDelete = new Playlist
            {
                Id          = 3,
                Name        = "Rock",
                Image       = "",
                Description = "Musica para gozar"
            };

            listPlaylist.Add(playlistDelete);
            var options = new DbContextOptionsBuilder <BetterCalmContext>()
                          .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options;
            var context = new BetterCalmContext(options);

            listPlaylist.ForEach(playlist => context.Add(playlist));
            context.SaveChanges();
            repository = new PlaylistRepository(context);
            repository.Delete(playlistDelete);
            context.Database.EnsureDeleted();
            Playlist getPlaylist = repository.Get(3);

            Assert.AreEqual(null, getPlaylist);
        }