public void Create() { queries.UpdateSongList(songListContract, null); var songList = repository.List <SongList>().FirstOrDefault(); Assert.IsNotNull(songList, "List was saved to repository"); Assert.AreEqual(songListContract.Name, songList.Name, "Name"); Assert.AreEqual(songListContract.Description, songList.Description, "Description"); Assert.AreEqual(2, songList.AllSongs.Count, "Number of songs"); Assert.AreEqual("Project Diva desu.", songList.AllSongs[0].Song.DefaultName, "First song as expected"); Assert.AreEqual("World is Mine", songList.AllSongs[1].Song.DefaultName, "Second song as expected"); }
public void Create() { _queries.UpdateSongList(_songListContract, null); var songList = _repository.List <SongList>().FirstOrDefault(); songList.Should().NotBeNull("List was saved to repository"); songList.Name.Should().Be(_songListContract.Name, "Name"); songList.Description.Should().Be(_songListContract.Description, "Description"); songList.AllSongs.Count.Should().Be(2, "Number of songs"); songList.AllSongs[0].Song.DefaultName.Should().Be("Project Diva desu.", "First song as expected"); songList.AllSongs[1].Song.DefaultName.Should().Be("World is Mine", "Second song as expected"); }
public ActionResult Edit(SongListEditViewModel model) { if (model == null) { return(HttpStatusCodeResult(HttpStatusCode.BadRequest, "View model was null - probably JavaScript is disabled")); } var coverPicUpload = Request.Files["thumbPicUpload"]; UploadedFileContract uploadedPicture = null; if (coverPicUpload != null && coverPicUpload.ContentLength > 0) { CheckUploadedPicture(coverPicUpload, "thumbPicUpload"); uploadedPicture = new UploadedFileContract { Mime = coverPicUpload.ContentType, Stream = coverPicUpload.InputStream }; } if (!ModelState.IsValid) { return(View(new SongListEditViewModel(model.ToContract(), PermissionContext))); } var listId = queries.UpdateSongList(model.ToContract(), uploadedPicture); return(RedirectToAction("Details", new { id = listId })); }
public ActionResult <int> Post(SongListForEditContract list) { if (list == null) { return(BadRequest()); } return(_queries.UpdateSongList(list, null)); }
public int Post(SongListForEditContract list) { if (list == null) { throw new HttpBadRequestException(); } return(queries.UpdateSongList(list, null)); }
public void AddSongToList(int listId, int songId, string newListName = null) { if (listId != 0) { Service.AddSongToList(listId, songId); } else if (!string.IsNullOrWhiteSpace(newListName)) { var contract = new SongListForEditContract { Name = newListName, SongLinks = new[] { new SongInListEditContract { SongId = songId, Order = 1 } } }; songListQueries.UpdateSongList(contract, null); } }
public ActionResult Edit(SongListEdit model) { var coverPicUpload = Request.Files["thumbPicUpload"]; UploadedFileContract uploadedPicture = null; if (coverPicUpload != null && coverPicUpload.ContentLength > 0) { CheckUploadedPicture(coverPicUpload, "thumbPicUpload"); uploadedPicture = new UploadedFileContract { Mime = coverPicUpload.ContentType, Stream = coverPicUpload.InputStream }; } if (!ModelState.IsValid) { return(View(model)); } var listId = queries.UpdateSongList(model.ToContract(), uploadedPicture); return(RedirectToAction("Details", new { id = listId })); }
public void AddSongToList(int listId, int songId, string notes = null, string newListName = null) { if (listId != 0) { Service.AddSongToList(listId, songId, notes ?? string.Empty); } else if (!string.IsNullOrWhiteSpace(newListName)) { var contract = new SongListForEditContract { Name = newListName, SongLinks = new[] { new SongInListEditContract { Song = new SongForApiContract { Id = songId }, Order = 1, Notes = notes ?? string.Empty } } }; _songListQueries.UpdateSongList(contract, null); } }