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");
        }
示例#2
0
        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");
        }
示例#3
0
        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 }));
        }
示例#4
0
        public ActionResult <int> Post(SongListForEditContract list)
        {
            if (list == null)
            {
                return(BadRequest());
            }

            return(_queries.UpdateSongList(list, null));
        }
示例#5
0
        public int Post(SongListForEditContract list)
        {
            if (list == null)
            {
                throw new HttpBadRequestException();
            }

            return(queries.UpdateSongList(list, null));
        }
示例#6
0
        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);
            }
        }
示例#7
0
        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 }));
        }
示例#8
0
        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);
            }
        }