public void SortTest() { Assert.AreEqual(_albumReview2.Rating, _albumReviewService.ListAlbumReviews(new AlbumReviewFilter { SortAscending = true }).First().Rating); var albumId = 3; var album3 = new AlbumDTO { ID = albumId, InterpretId = _interpret2Id, Name = "Hybrid Theory", Year = 2000 }; _albumService.CreateAlbum(album3, _interpret2Id); var albumReview = new AlbumReviewDTO { AlbumId = albumId, Note = "Not bad", Rating = 9, ID = _albumReview2Id }; _albumReviewService.CreateAlbumReview(albumReview, albumId); Assert.AreEqual(_albumReview1.Rating, _albumReviewService.ListAlbumReviews(new AlbumReviewFilter { SortAscending = false }).First().Rating); }
public void CreateAlbumReview(AlbumReviewDTO albumReviewDto, int albumId) { using (var uow = UnitOfWorkProvider.Create()) { var albumReview = Mapper.Map <AlbumReview>(albumReviewDto); albumReview.Album = GetAlbumReviewAlbum(albumId); _albumReviewRepository.Insert(albumReview); uow.Commit(); } }
public void EditAlbumReview(AlbumReviewDTO albumReviewDto, int albumId) { using (var uow = UnitOfWorkProvider.Create()) { var albumReview = _albumReviewRepository.GetById(albumReviewDto.ID); Mapper.Map(albumReviewDto, albumReview); albumReview.Album = GetAlbumReviewAlbum(albumId); _albumReviewRepository.Update(albumReview); uow.Commit(); } }
/// <summary> /// Adds a review /// </summary> /// <param name="reviewDTO">Review details</param> public void AddReview(AlbumReviewDTO reviewDTO) { if (reviewDTO == null) { throw new ArgumentNullException("AlbumReview service - AddReview(...) reviewDTO cannot be null"); } using (var uow = UnitOfWorkProvider.Create()) { var review = Mapper.Map <AlbumReview>(reviewDTO); review.Album = GetReviewAlbum(reviewDTO.AlbumID); albumReviewRepository.Insert(review); uow.Commit(); } }
/// <summary> /// Updates review /// </summary> /// <param name="reviewDTO">Update details</param> public void EditAlbumReview(AlbumReviewDTO reviewDTO) { if (reviewDTO == null) { throw new ArgumentNullException("Album review service - EditAlbumReview(...) reviewDTO cannot be null"); } using (var uow = UnitOfWorkProvider.Create()) { var review = albumReviewRepository.GetByID(reviewDTO.ID, albumReview => albumReview.Album); if (review == null) { throw new NullReferenceException("Album review service - EditReview(...) the review cannot be null"); } Mapper.Map(reviewDTO, review); albumReviewRepository.Update(review); uow.Commit(); } }
public void CreateAlbumReview(AlbumReviewDTO albumReviewDTO) { if (albumReviewDTO == null) { throw new ArgumentNullException("Album review service - CreateReview(...) review cannot be null"); } using (var uow = UnitOfWorkProvider.Create()) { var albumReview = Mapper.Map <AlbumReviewDTO, AlbumReview>(albumReviewDTO); albumReview.Album = GetReviewAlbum(albumReview.Album.ID); if (albumReview == null) { throw new NullReferenceException("Album review service - CreateReview(...) albumReview cannot be null(could not be found)"); } albumReview.Creator = GetAlbumReviewCreator(albumReviewDTO.CreatorID); albumReviewRepository.Insert(albumReview); uow.Commit(); } }
public void EditAlbumReview(AlbumReviewDTO albumReviewDto, int albumId) { _albumReviewService.EditAlbumReview(albumReviewDto, albumId); }
public void CreateAlbumReview(AlbumReviewDTO albumReviewDto, int albumId) { _albumReviewService.CreateAlbumReview(albumReviewDto, albumId); }
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 = _interpret1Id, Name = "Toxicity", Year = 2003 }; _album2Id = 2; _album2 = new AlbumDTO { ID = _album2Id, InterpretId = _interpret2Id, Name = "Meteora", Year = 2008 }; _albumService.CreateAlbum(_album1, _interpret1Id); _albumService.CreateAlbum(_album2, _interpret2Id); _albumReview1Id = 1; _albumReview1 = new AlbumReviewDTO { ID = _albumReview1Id, AlbumId = _album1.ID, Note = "Perfect album", Rating = 9 }; _albumReview2Id = 2; _albumReview2 = new AlbumReviewDTO { AlbumId = _album2.ID, Note = "Not bad", Rating = 8, ID = _albumReview2Id }; _albumReviewService.CreateAlbumReview(_albumReview1, _album1Id); _albumReviewService.CreateAlbumReview(_albumReview2, _album2Id); }
public void EditReview(AlbumReviewDTO reviewDTO) { albumReviewService.EditAlbumReview(reviewDTO); }
public void AddReview(AlbumReviewDTO reviewDTO) { albumReviewService.AddReview(reviewDTO); }
public void CreateReview(AlbumReviewDTO reviewDTO) { albumReviewService.CreateAlbumReview(reviewDTO); }
private static void TestAlbumReviewService() { List <int> list = new List <int>(); albumReviewService = Container.Resolve <IAlbumReviewService>(); clientService = Container.Resolve <IClientService>(); //Create albumReviewService.CreateAlbumReview(new AlbumReviewDTO { Text = "This disc is a great improvement on an already brilliant EP, keeping the same style with great screams and guitars and improving melodically, lyrically and each song delivering a catchy chorus.", AlbumID = albumID, CreatorID = clientID, }); albumReviewService.CreateAlbumReview(new AlbumReviewDTO { Text = "I remember listening to The Poison, 10 years ago when this style of metalcore was at an incredibly high popularity. I definitely didn’t hate it but still preferred to listen to other bands of even similar genres.", AlbumID = albumID, CreatorID = clientID2, }); //ListAllAlbumReviews var albumReviews = albumReviewService.ListAllAlbumReviews(new AlbumReviewFilter { AlbumID = albumID }, 1); Console.WriteLine(albumReviews.TotalResultCount == 2 ? "AlbumReviewService - TestListAllAlbumReviews - OK" : "AlbumReviewService - TestListAllAlbumReviews - FAIL"); //GetAlbumReviewById var reviews = albumReviewService.ListAllAlbumReviews(new AlbumReviewFilter { CreatorIDs = new List <int> { clientID } }, 1); AlbumReviewDTO albumReview = reviews.ResultsPage.FirstOrDefault(); var testedReview = albumReviewService.GetAlbumReview(albumReview.ID); Console.WriteLine(testedReview.ID == albumReview.ID ? "AlbumReviewService - TestGetAlbumReviewById - OK" : "AlbumReviewService - TestGetAlbumReviewById - FAIL"); //AddAlbumReview reviews = albumReviewService.ListAllAlbumReviews(new AlbumReviewFilter { CreatorIDs = new List <int> { clientID2 } }, 1); AlbumReviewDTO review2 = reviews.ResultsPage.FirstOrDefault(); albumReviewService.AddReview(albumReview); albumReviewService.AddReview(review2); AlbumDTO album = albumService.GetAlbum(albumID); Console.WriteLine(album.ReviewIDs.Contains(review2.ID) ? "AlbumReviewService - TestAddAlbumReview - OK" : "AlbumReviewService - TestAddAlbumReview - FAIL"); //TestAlbumServisGetAllAlbumReviews Console.WriteLine(album.ReviewIDs.Count() == 2 ? "AlbumService - TestAlbumServisGetAllAlbumReviews - OK" : "AlbumService - TestAlbumServisGetAllAlbumReviews - FAIL"); //EditAlbumReview review2.Text = "1010"; albumReviewService.EditAlbumReview(review2); AlbumReviewDTO review2FromDB = albumReviewService.GetAlbumReview(review2.ID); Console.WriteLine(review2FromDB.Text == "1010" ? "AlbumReviewService - TestEditAlbumReview - OK" : "AlbumReviewService - TestEditAlbumReview - FAIL"); //DeleteAlbumReview albumReviewService.DeleteAlbumReview(review2.ID); AlbumReviewDTO venomFromDB = albumReviewService.GetAlbumReview(review2.ID); Console.WriteLine(venomFromDB == null ? "AlbumReviewService - TestDeleteAlbumReview - OK" : "AlbumReviewService - TestDeleteAlbumReview - FAIL"); //GetCreator ClientDTO creator = albumReviewService.GetCreator(albumReview.ID); Console.WriteLine(creator.ID == clientID ? "AlbumReviewService - TestGetCreator - OK" : "AlbumReviewService - TestGetCreator - FAIL"); }