public void AddSongToInventory_AddSongViewModel_AddsSongToDatabase() { var album = new Album { Id = Guid.NewGuid(), AlbumId = Guid.NewGuid() }; var artist = new Artist { Id = Guid.NewGuid(), ArtistId = Guid.NewGuid() }; var viewModel = new AddSongViewModel { AlbumId = album.AlbumId, Name = "Basic B", ArtistIds = new List <Guid> { artist.ArtistId } }; _context.Albums.Add(album); _context.Artists.Add(artist); _context.SaveChanges(); _inventoryController.AddSongToInventory(viewModel); var songs = _context.Songs.ToList(); const int expected = 1; Assert.AreEqual(expected, songs.Count); }
public ActionResult AddSong(int Id) { AddSongViewModel model = new AddSongViewModel(); model.BandsRecordId = Id; return(View(model)); }
public IHttpActionResult AddSongToInventory(AddSongViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest("Invalid Model State")); } var song = _mapper.Map <Song>(viewModel); _inventoryService.AddSong(song); return(Ok()); }
public IActionResult AddSong() { var model = new AddSongViewModel(); List <SongGenreTagViewModel> genreTags = new List <SongGenreTagViewModel>(); foreach (var item in _applicationDbContext.MusicGenres.ToList()) { genreTags.Add(new SongGenreTagViewModel { Id = item.Id, Name = item.Name }); } model.SongGenreTags = genreTags; return(View(model)); }
public ActionResult AddSong(AddSongViewModel model) { if (ModelState.IsValid) { bool value = repository.AddSongToBandsRecord(model); if (value) { return(RedirectToAction("SongList", new { Id = model.BandsRecordId })); } else { return(View("Error", $"Dodanie utworu nie powiodło się ")); } } else { return(View("AddSong", model)); } }
public IActionResult AddSong(int id, AddSongViewModel model) { if (!TryValidateModel(model)) { return(View(model)); } var newSong = new Song() { //Id = model.Id, Titel = model.Title, Artist = model.Artist, Release = model.Release, AlbumId = id }; _applicationDbContext.Songs.Add(newSong); _applicationDbContext.SaveChanges(); List <SongGenre> selectedSongGenre = new List <SongGenre>(); foreach (var genre in model.SongGenreTags) { if (genre.Checked == true) { _applicationDbContext.SongGenres.Add(new SongGenre { MusicGenreId = genre.Id, SongId = newSong.Id }); //selectedSongGenre.Add(new SongGenre { MusicGenreId = genre.Id, SongId = newSong.Id }); } } newSong.GenresSong = selectedSongGenre; //_applicationDbContext.Songs.Update(newSong); _applicationDbContext.SaveChanges(); return(RedirectToAction("DetailAlbum", new { id = id })); }
public AddSong() { InitializeComponent(); BindingContext = model = new AddSongViewModel(); }
public IActionResult AddSong() { var model = new AddSongViewModel(); return(View(model)); }
public AddSong(string username) { InitializeComponent(); DataContext = new AddSongViewModel(this, username); }
public AddSong() { InitializeComponent(); DataContext = new AddSongViewModel(this); }
private void SetAddNewSongViewModel(bool truth) { VariableViewModel = new AddSongViewModel(); }
public AddItemViewModelTest() { MusicStructureHelper.InitializeDB(); sut = new AddSongViewModel(); }