Beispiel #1
0
        public void Setup()
        {
            albumRepositoryMock  = new Mock <IEfRepository <Album> >();
            artistRepositoryMock = new Mock <IEfRepository <Artist> >();
            songRepositoryMock   = new Mock <IEfRepository <Song> >();
            genreRepositoryMock  = new Mock <IEfRepository <Genre> >();
            unitOfWorkMock       = new Mock <IUnitOfWork>();
            dateTimeMock         = new Mock <IDateTimeProvider>();
            artist       = new Artist();
            album        = new Album();
            album.Artist = artist;
            genre        = new Genre();
            genreId      = new Guid();
            albumId      = new Guid();
            song         = new Song();
            name         = "song1";
            duration     = 5;
            service      = new SongService(songRepositoryMock.Object,
                                           albumRepositoryMock.Object,
                                           genreRepositoryMock.Object,
                                           artistRepositoryMock.Object,
                                           unitOfWorkMock.Object,
                                           dateTimeMock.Object);

            albumRepositoryMock.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(album);
            genreRepositoryMock.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(genre);
            service.AddSong(name, duration, genreId, albumId);
        }
Beispiel #2
0
        public async Task <IActionResult> Upload(List <IFormFile> files)
        {
            var success = true;

            foreach (var file in files)
            {
                if (!await _songService.AddSong(file))
                {
                    success = false;
                }
            }

            if (success)
            {
                return(new OkResult());
            }
            return(StatusCode(500));
        }
Beispiel #3
0
        async Task AddSong(Song song)
        {
            var name = await Application.Current.MainPage.DisplayPromptAsync("Name", "NameMessage");

            var singer = await Application.Current.MainPage.DisplayPromptAsync("Singer", "SingerMessage");

            var length = await Application.Current.MainPage.DisplayPromptAsync("Length", "length");

            await SongService.AddSong(name, singer, length);

            await Refresh();
        }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "Id,Title,Duration,Appearances,IsCover,Genre,GenreId")] Song song)
        {
            ViewBag.GenreId = new SelectList(db.Genres, "Id", "Title", song.GenreId);
            var songVM = new SongViewModel
            {
                Id          = song.Id,
                Title       = song.Title,
                Duration    = song.Duration,
                Appearances = song.Appearances,
                IsCover     = song.IsCover,
                Genre       = song.Genre,
                GenreId     = song.GenreId
            };

            if (ModelState.IsValid)
            {
                ss.AddSong(song);
                return(RedirectToAction("Index"));
            }
            return(View(songVM));
        }
 public IActionResult AddSong([FromBody] Song song)
 {
     songService.AddSong(song);
     return(Ok());
 }