public void CreateSongReview(SongReviewDTO songReviewDto, int songId)
 {
     using (var uow = UnitOfWorkProvider.Create())
     {
         var songReview = Mapper.Map <SongReview>(songReviewDto);
         songReview.Song = GetSongReviewSong(songId);
         _songReviewRepository.Insert(songReview);
         uow.Commit();
     }
 }
 public void EditSongReview(SongReviewDTO songReviewDto, int songId)
 {
     using (var uow = UnitOfWorkProvider.Create())
     {
         var songReview = _songReviewRepository.GetById(songReviewDto.ID);
         Mapper.Map(songReviewDto, songReview);
         songReview.Song = GetSongReviewSong(songId);
         _songReviewRepository.Update(songReview);
         uow.Commit();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a review
        /// </summary>
        /// <param name="reviewDTO">Review details</param>
        public void AddReview(SongReviewDTO reviewDTO)
        {
            if (reviewDTO == null)
            {
                throw new NullReferenceException("SongReview Service - AddReview(...) reviewDTO cannot be null");
            }

            using (var uow = UnitOfWorkProvider.Create())
            {
                var review = Mapper.Map <SongReview>(reviewDTO);
                review.Song = GetReviewSong(reviewDTO.SongID);
                songReviewRepository.Insert(review);
                uow.Commit();
            }
        }
Exemplo n.º 4
0
        public void CreateSongReviewTest()
        {
            Assert.AreEqual(2, _songReviewService.ListSongReviews(null).Count());

            var songReview3 = new SongReviewDTO
            {
                SongId = _song3Id,
                ID     = 3,
                Note   = "Great!",
                Rating = 10
            };

            _songReviewService.CreateSongReview(songReview3, _song3Id);

            Assert.AreEqual(3, _songReviewService.ListSongReviews(null).Count());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Updates review
        /// </summary>
        /// <param name="reviewDTO">Update details</param>
        public void EditSongReview(SongReviewDTO reviewDTO)
        {
            if (reviewDTO == null)
            {
                throw new ArgumentOutOfRangeException("SongReview Service - EditSongReview(...) reviewDTO cannot be null");
            }

            using (var uow = UnitOfWorkProvider.Create())
            {
                var review = songReviewRepository.GetByID(reviewDTO.ID, songReview => songReview.Song);
                if (review == null)
                {
                    throw new NullReferenceException("Song review service - EditReview(...) the review cannot be null");
                }
                Mapper.Map(reviewDTO, review);
                songReviewRepository.Update(review);
                uow.Commit();
            }
        }
Exemplo n.º 6
0
        public void CreateSongReview(SongReviewDTO songReviewDTO)
        {
            if (songReviewDTO == null)
            {
                throw new NullReferenceException("SongReview Service - CreateSongReview(...) songReviewDTO cannot be null");
            }

            if (songReviewDTO == null)
            {
                throw new NullReferenceException("Song review service - CreateReview(...) review cannot be null");
            }
            using (var uow = UnitOfWorkProvider.Create())
            {
                var songReview = Mapper.Map <SongReviewDTO, SongReview>(songReviewDTO);
                songReview.Song    = GetReviewSong(songReview.Song.ID);
                songReview.Creator = GetSongReviewCreator(songReviewDTO.CreatorID);


                songReviewRepository.Insert(songReview);
                uow.Commit();
            }
        }
Exemplo n.º 7
0
 public void EditSongReview(SongReviewDTO songReviewDto, int songId)
 {
     _songReviewService.EditSongReview(songReviewDto, songId);
 }
Exemplo n.º 8
0
 public void CreateSongReview(SongReviewDTO songReviewDto, int songId)
 {
     _songReviewService.CreateSongReview(songReviewDto, songId);
 }
Exemplo n.º 9
0
 public void AddReview(SongReviewDTO reviewDTO)
 {
     songReviewService.AddReview(reviewDTO);
 }
Exemplo n.º 10
0
 public void CreateReview(SongReviewDTO reviewDTO)
 {
     songReviewService.CreateSongReview(reviewDTO);
 }
Exemplo n.º 11
0
 public void EditReview(SongReviewDTO reviewDTO)
 {
     songReviewService.EditSongReview(reviewDTO);
 }
Exemplo n.º 12
0
        public void Init()
        {
            _interpret1Id = 1;
            _interpret1   = new InterpretDTO
            {
                Name     = "System of a down",
                Language = Language.English,
                ID       = _interpret1Id
            };

            _interpret2Id = 2;
            _interpret2   = new InterpretDTO
            {
                Name     = "Linkin Park",
                Language = Language.English,
                ID       = _interpret2Id
            };

            _interpretService.CreateInterpret(_interpret1);
            _interpretService.CreateInterpret(_interpret2);

            _album1Id = 1;
            _album1   = new AlbumDTO
            {
                ID          = _album1Id,
                InterpretId = 1,
                Name        = "Toxicity",
                Year        = 2001
            };

            _album2Id = 2;
            _album2   = new AlbumDTO
            {
                ID          = _album2Id,
                InterpretId = 2,
                Name        = "Meteora",
                Year        = 2003
            };
            _albumService.CreateAlbum(_album1, _interpret1.ID);
            _albumService.CreateAlbum(_album2, _interpret2.ID);

            _song1Id = 1;
            _song1   = new SongDTO
            {
                ID      = _song1Id,
                Name    = "Prison Song",
                Added   = new DateTime(2016, 11, 6),
                AlbumId = _album1Id,
                Genre   = Genre.Rock
            };

            _song2Id = 2;
            _song2   = new SongDTO
            {
                ID      = _song2Id,
                Name    = "Deer Dance",
                Added   = new DateTime(2016, 11, 6),
                AlbumId = _album1Id,
                Genre   = Genre.Rock
            };

            _song3Id = 3;
            _song3   = new SongDTO
            {
                ID      = _song3Id,
                Name    = "Numb",
                Added   = new DateTime(2016, 11, 6),
                AlbumId = _album2Id,
                Genre   = Genre.Rock
            };

            _songService.CreateSong(_song1, _album1Id);
            _songService.CreateSong(_song2, _album1Id);
            _songService.CreateSong(_song3, _album2Id);

            _songReview1Id = 1;
            _songReview1   = new SongReviewDTO
            {
                ID     = _songReview1Id,
                SongId = _song1.ID,
                Note   = "Perfect album",
                Rating = 9
            };

            _songReview2Id = 2;
            _songReview2   = new SongReviewDTO
            {
                SongId = _song2.ID,
                Note   = "Not bad",
                Rating = 8,
                ID     = _songReview2Id
            };

            _songReviewService.CreateSongReview(_songReview1, _song1Id);
            _songReviewService.CreateSongReview(_songReview2, _song2Id);
        }
Exemplo n.º 13
0
        private static void TestSongReviewService()
        {
            List <int> list = new List <int>();

            songReviewService = Container.Resolve <ISongReviewService>();
            clientService     = Container.Resolve <IClientService>();

            //Create
            songReviewService.CreateSongReview(new SongReviewDTO
            {
                Text      = "Reminds me of my dreaded youth.",
                SongID    = songID,
                CreatorID = clientID,
            });
            songReviewService.CreateSongReview(new SongReviewDTO
            {
                Text      = "One of the best songs, on their best album!",
                SongID    = songID,
                CreatorID = clientID2,
            });
            songReviewService.CreateSongReview(new SongReviewDTO
            {
                Text      = "This video actually makes sense unlike other songs, and the video matches the lyrics 2 boot! I LOVE IT!!! sry, sugar rush (still worst joke ever) sry, but anyway, this video is very good, SO GOOD!!! ",
                SongID    = songID2,
                CreatorID = clientID,
            });

            //ListAllSongReviews
            var songReviews = songReviewService.ListAllSongReviews(new SongReviewFilter {
                SongID = songID
            }, 1);

            Console.WriteLine(songReviews.TotalResultCount == 2 ? "SongReviewService - TestListAllSongReviews - OK" : "SongReviewService - TestListAllSongReviews - FAIL");

            //GetSongReviewById
            var           reviews      = songReviewService.ListAllSongReviews(null, 1);
            SongReviewDTO songReview   = reviews.ResultsPage.FirstOrDefault();
            var           testedReview = songReviewService.GetSongReview(songReview.ID);

            Console.WriteLine(testedReview.ID == songReview.ID ? "SongReviewService - TestGetSongReviewById - OK" : "SongReviewService - TestGetSongReviewById - FAIL");

            //AddSongReview
            SongReviewDTO review2 = reviews.ResultsPage.ElementAt(1);
            SongReviewDTO review3 = reviews.ResultsPage.LastOrDefault();

            reviews    = songReviewService.ListAllSongReviews(null, 1);
            songReview = reviews.ResultsPage.ElementAt(1);
            songReviewService.AddReview(songReview);
            songReviewService.AddReview(review2);
            songReviewService.AddReview(review3);
            SongDTO song = songService.GetSong(songID);

            Console.WriteLine(song.ReviewIDs.Contains(songReview.ID) ?
                              "SongReviewService - TestAddSongReview - OK" : "SongReviewService - TestAddSongReview - FAIL");

            //TestSongServisGetAllSongReviews
            Console.WriteLine(song.ReviewIDs.Count() == 2 ?
                              "SongService - TestSongServisGetAllSongReviews - OK" : "SongService - TestSongServisGetAllSongReviews - FAIL");

            //EditSongReview
            review2.Text = "1010";
            songReviewService.EditSongReview(review2);
            SongReviewDTO review2FromDB = songReviewService.GetSongReview(review2.ID);

            Console.WriteLine(review2FromDB.Text == "1010" ? "SongReviewService - TestEditSongReview - OK" : "SongReviewService - TestEditSongReview - FAIL");

            //DeleteSongReview
            songReviewService.DeleteSongReview(review2.ID);
            SongReviewDTO reviewFromDB = songReviewService.GetSongReview(review2.ID);

            Console.WriteLine(reviewFromDB == null ? "SongReviewService - TestDeleteSongReview - OK" : "SongReviewService - TestDeleteSongReview - FAIL");

            //GetCreator
            ClientDTO creator = songReviewService.GetCreator(songReview.ID);

            Console.WriteLine(creator.ID == clientID ? "SongReviewService - TestGetCreator - OK" : "SongReviewService - TestGetCreator - FAIL");
        }