示例#1
0
        public void CreateSong(SongDTO songDTO)
        {
            if (songDTO == null)
            {
                throw new ArgumentNullException("Song service - CreateSong(...) songDTO cannot be null");
            }

            SongReview review;
            var        song = Mapper.Map <Song>(songDTO);

            using (var uow = UnitOfWorkProvider.Create())
            {
                song.Album   = GetSongAlbum(songDTO.AlbumID);
                song.Creator = clientRepository.GetByID(songDTO.CreatorID);
                if (songDTO.ReviewIDs != null)
                {
                    foreach (int ID in songDTO.ReviewIDs)
                    {
                        review = GetSongReview(ID);
                        song.Reviews.Add(review);
                    }
                }

                songRepository.Insert(song);
                uow.Commit();
            }
        }
示例#2
0
        public void create()
        {
            SongDTO sDTO = new SongDTO(name, trackNo, duration, songtext, album);
            SongDAO sDAO = new SongDAO();

            sDAO.insertSong(sDTO);
        }
示例#3
0
 public IActionResult Delete(int id)
 {
     try
     {
         var songToDelete = _context.Songs.Where(s => s.Id == id).FirstOrDefault();
         if (songToDelete != null)
         {
             SongDTO copyOfSong = new SongDTO {
                 Id          = songToDelete.Id, Album = songToDelete.Album,
                 Artist      = songToDelete.Artist, Title = songToDelete.Title,
                 ReleaseDate = songToDelete.ReleaseDate, Likes = songToDelete.Likes
             };
             _context.Remove(songToDelete);
             _context.SaveChanges();
             return(StatusCode(200, copyOfSong));
         }
         else
         {
             return(StatusCode(400));
         }
     }
     catch
     {
         return(StatusCode(500));
     }
 }
示例#4
0
 public void GetAllSongs()
 {
     using (var context = new MusicAppDb())
     {
         context.Songs.ToList().Select(x => SongDTO.FromEntity(x)).ToList().ForEach(x => Console.WriteLine(x.NameAndDuration));
     }
 }
示例#5
0
        public async Task <IActionResult> PutSong(int id, SongDTO song)
        {
            if (ModelState.IsValid)
            {
                if (id != song.Id)
                {
                    return(BadRequest());
                }

                try
                {
                    await this._songService.UpdateAsync(id, song);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await SongExistsAsync(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        return(BadRequest());
                    }
                }

                return(NoContent());
            }
            else
            {
                return(BadRequest());
            }
        }
示例#6
0
 public ArtistController()
 {
     services = new GoogleDriveServices(HttpContext.Current.Server.MapPath("~/"));
     dto      = new ArtistDTO(HttpContext.Current.Request.Url);
     albumDto = new AlbumDTO(HttpContext.Current.Request.Url);
     songDto  = new SongDTO(HttpContext.Current.Request.Url);
 }
        public IActionResult Get(int id)
        {
            //Song ThatOneSong = _context.Songs.Where(song => song.Id == id).FirstOrDefault();
            SongDTO ThatOneSong = songDTOs.Where(song => song.Id == id).FirstOrDefault();

            return(Ok(ThatOneSong));
        }
示例#8
0
        public MusicGameController()
        {
            Uri uri = HttpContext.Current.Request.Url;

            dto     = new ScoreDTO(uri);
            songDto = new SongDTO(uri);
        }
示例#9
0
 public IActionResult AddLike(int id)
 {
     try
     {
         Song song = _context.Songs.Where(s => s.Id == id).FirstOrDefault();
         if (song == null)
         {
             return(BadRequest());
         }
         else
         {
             song.Likes += 1;
             _context.Update(song);
             _context.SaveChanges();
             SongDTO returnVal = new SongDTO()
             {
                 Id = song.Id, Title = song.Title, Album = song.Album, Artist = song.Artist, ReleaseDate = song.ReleaseDate, Likes = song.Likes
             };
             return(StatusCode(200, returnVal));
         }
     }
     catch
     {
         return(StatusCode(500));
     }
 }
示例#10
0
 public void AddSong(SongDTO song)
 {
     using (SqlConnection connection = new SqlConnection("Data Source=(LocalDB)\\v11.0;AttachDbFilename=D:\\Git\\Gramophone.Web\\App_Data\\GramophoneDB.mdf;Integrated Security=True"))
     {
         connection.Open();
         using (SqlCommand cmd = connection.CreateCommand())
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.CommandText = "SP_AddNewSong";
             cmd.Connection  = connection;
             cmd.Parameters.AddWithValue("@SongTitle", song.SongTitle);
             cmd.Parameters.AddWithValue("@Singer1ID", song.Singer1);
             cmd.Parameters.AddWithValue("@Singer2ID", song.Singer2);
             cmd.Parameters.AddWithValue("@Singer3ID", song.Singer3);
             cmd.Parameters.AddWithValue("@ComposerID", song.Composer);
             cmd.Parameters.AddWithValue("@DirectorID", song.Director);
             cmd.Parameters.AddWithValue("@MusicianID", song.Musician);
             cmd.Parameters.AddWithValue("@AlbumID", song.Album);
             cmd.Parameters.AddWithValue("@Year", song.Year);
             cmd.Parameters.AddWithValue("@Lyrics", DBNull.Value);
             cmd.Parameters.AddWithValue("@Image", DBNull.Value);
             cmd.Parameters.AddWithValue("@YouTubeURL", song.YouTubeURL);
             cmd.ExecuteNonQuery();
         }
         connection.Close();
     }
 }
示例#11
0
        public Boolean updateSongAlbumArtist(SongDTO dto)
        {
            Boolean check = false;

            using (sqlConnection = new SqlConnection(connectionString))
            {
                try
                {
                    sqlConnection.Open();
                    command = new SqlCommand("UPDATE Song_Album_Artist SET albumID = @albumID, artistID = @artistID " +
                                             "WHERE songID= @id", sqlConnection);
                    command.Parameters.AddWithValue("@id", dto.ID);
                    command.Parameters.AddWithValue("@albumID", dto.Album.Id);
                    command.Parameters.AddWithValue("@artistID", dto.Artis.Id);
                    check = command.ExecuteNonQuery() > 0;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
                finally
                {
                    closeConnect();
                }
            }
            return(check);
        }
        public IActionResult Put(int id, [FromBody] SongDTO UpdatedSongDTO)
        {
            SongDTO songDTOToUpdate = songDTOs.Where(song => song.Id == id).FirstOrDefault();

            try
            {
                songDTOToUpdate.Album       = UpdatedSongDTO.Album;
                songDTOToUpdate.Artist      = UpdatedSongDTO.Artist;
                songDTOToUpdate.Title       = UpdatedSongDTO.Title;
                songDTOToUpdate.ReleaseDate = UpdatedSongDTO.ReleaseDate;

                Song songToUpdate = DTOToSong(songDTOToUpdate);
                if (UpdatedSongDTO.LikesSong)
                {
                    songDTOToUpdate.LikesSong = false;
                    songToUpdate.Likes++;
                }
                songDTOToUpdate.DisplayLikes = songToUpdate.Likes;
                _context.Update(songToUpdate);
                _context.SaveChanges();
                songDTOs = SongsConverter(_context.Songs.ToList());

                return(Ok(songDTOToUpdate));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Something went wrong: {ex}");
                return(StatusCode(400, "Bad Request, Object Not found"));
            }
        }
示例#13
0
        public Boolean updateSongs(SongDTO dto)
        {
            Boolean check = false;

            using (sqlConnection = new SqlConnection(connectionString))
            {
                try
                {
                    sqlConnection.Open();
                    command = new SqlCommand("UPDATE Songs SET title = @title, lyrics = @lyrics, dateRelease = @dateRelease, " +
                                             "linkDownLoad = @linkDownLoad " +
                                             "WHERE ID = @id", sqlConnection);
                    command.Parameters.AddWithValue("@id", dto.ID);
                    command.Parameters.AddWithValue("@title", dto.Title);
                    command.Parameters.AddWithValue("@lyrics", dto.Lyrics);
                    command.Parameters.AddWithValue("@dateRelease", dto.DateRelease);
                    command.Parameters.AddWithValue("@linkDownLoad", dto.LinkDownLoad);
                    check = command.ExecuteNonQuery() > 0;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
                finally
                {
                    closeConnect();
                }
            }
            return(check);
        }
示例#14
0
        public List <SongDTO> loadAllSongs()
        {
            int            songID;
            string         title, lyrics, dateRelease, linkOpen, linkDownLoad, image;
            ArtistDTO      artis;
            int            artisID;
            string         artisName;
            AlbumDTO       album;
            int            albumID;
            string         albumName;
            SongDTO        song   = null;
            List <SongDTO> result = new List <SongDTO>();

            using (sqlConnection = new SqlConnection(connectionString))
            {
                try
                {
                    sqlConnection.Open();
                    using (command = new SqlCommand("" +
                                                    "Select Songs.ID, Songs.title,Songs.lyrics,Songs.dateRelease,Songs.linkOpen,Songs.linkDownLoad,Songs.image,Artists.ID,Artists.name,Albums.ID,Albums.name " +
                                                    "From Songs, Artists, Albums, Song_Album_Artist " +
                                                    "Where Song_Album_Artist.albumID = Albums.ID AND Song_Album_Artist.songID = Songs.ID AND Song_Album_Artist.artistID = Artists.ID",
                                                    sqlConnection))
                        using (reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                //songs
                                songID       = reader.GetInt32(0);
                                title        = reader.GetString(1);
                                lyrics       = reader.GetString(2);
                                dateRelease  = reader.GetDateTime(3).ToString("yyyy-MM-dd");
                                linkOpen     = reader.GetString(4);
                                linkDownLoad = reader.GetString(5);
                                image        = reader.GetString(6);
                                //artis
                                artisID   = reader.GetInt32(7);
                                artisName = reader.GetString(8);
                                artis     = new ArtistDTO(artisID, artisName);
                                //album
                                albumID   = reader.GetInt32(9);
                                albumName = reader.GetString(10);
                                album     = new AlbumDTO(albumID, albumName);

                                song = new SongDTO(songID, title, lyrics, dateRelease, linkOpen, linkDownLoad, image, artis, album);
                                result.Add(song);
                            }
                        }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
                finally
                {
                    closeConnect();
                }
            }
            return(result);
        }
示例#15
0
        public Boolean addSongArtistAndAlbum(SongDTO dto)
        {
            Boolean check = false;

            using (sqlConnection = new SqlConnection(connectionString))
            {
                try
                {
                    sqlConnection.Open();
                    using (command = new SqlCommand("Insert into " +
                                                    "Song_Album_Artist(songID,albumID,artistID) " +
                                                    "Values (@songID, @albumID, @artistID)", sqlConnection))
                    {
                        command.Parameters.AddWithValue("@songID", dto.ID);
                        command.Parameters.AddWithValue("@albumID", dto.Album.Id);
                        command.Parameters.AddWithValue("@artistID", dto.Artis.Id);
                        check = command.ExecuteNonQuery() > 0;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
                finally
                {
                    closeConnect();
                }
            }
            return(check);
        }
示例#16
0
        public Boolean addSong(SongDTO dto, int time)
        {
            Boolean check = false;

            using (sqlConnection = new SqlConnection(connectionString))
            {
                try
                {
                    sqlConnection.Open();
                    using (command = new SqlCommand("Insert into " +
                                                    " Songs(ID,title,lyrics,dateRelease,linkOpen,linkDownLoad,image,time) " +
                                                    " Values (@ID, @title, @lyrics, @dateRelease, @linkOpen, @linkDownLoad,@image,@time)", sqlConnection))
                    {
                        command.Parameters.AddWithValue("@ID", dto.ID);
                        command.Parameters.AddWithValue("@title", dto.Title);
                        command.Parameters.AddWithValue("@lyrics", dto.Lyrics);
                        command.Parameters.AddWithValue("@dateRelease", dto.DateRelease);
                        command.Parameters.AddWithValue("@linkOpen", dto.LinkOpen);
                        command.Parameters.AddWithValue("@linkDownLoad", dto.LinkDownLoad);
                        command.Parameters.AddWithValue("@image", dto.Image);
                        command.Parameters.AddWithValue("@time", time);
                        check = command.ExecuteNonQuery() > 0;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
                finally
                {
                    closeConnect();
                }
            }
            return(check);
        }
        public ActionResult InfoSong(int idPerformer, int?idSong, string sort = "ascName")
        {
            SongDTO songDto = SongServices.GetById(idSong);
            var     song    = _mapper.Map <SongDTO, SongViewModel>(songDto);

            ViewBag.Sort = sort;
            return(View(song));
        }
示例#18
0
        public async Task <OperationResult <SongDTO> > Save(SongDTO songDTO)
        {
            var song = mapper.Map <Song>(songDTO);
            // Validation for songs could be added here, return a non-success if something was wrong
            await songRepository.Save(song);

            return(OperationResult <SongDTO> .CreateSuccessResult(mapper.Map <SongDTO>(song)));
        }
示例#19
0
        public ActionResult SaveAccords(int idSong, string strAccords)
        {
            string[] arrAccords = strAccords.Split(',');
            SongDTO  updateSong = Services.SaveAccords(arrAccords, idSong);
            var      song       = _mapper.Map <SongDTO, SongViewModel>(updateSong);

            return(View("InfoSong", song));
        }
示例#20
0
 public void updateMetaDataLabels(SongDTO song)
 {
     Album.Content              = song.songTag.getAlbum();
     Artist.Content             = song.songTag.getArtist();
     this.durationLabel.Content = song.songTag.getDuration().ToString(@"mm\:ss");
     //metadataLabels.Thumbnail.Image = songDTO.songTag.getThumbnail();
     this.titleLabel.Content = song.songTag.getTitle();
     setTimeLabel(new TimeSpan(0));
 }
示例#21
0
        public UsersController()
        {
            services = new GoogleDriveServices(HttpContext.Current.Server.MapPath("~/"));
            Uri uri = HttpContext.Current.Request.Url;

            dto         = new UserInfoDTO(uri);
            playlistDto = new PlaylistDTO(uri);
            songDto     = new SongDTO(uri);
        }
示例#22
0
        public SongController()
        {
            services = new GoogleDriveServices(HttpContext.Current.Server.MapPath("~/"));
            Uri uri = HttpContext.Current.Request.Url;

            dto            = new SongDTO(uri);
            commentDto     = new CommentDTO(uri);
            rankingSongDto = new RankingSongDTO(uri);
        }
示例#23
0
 public void updateSongMetadataInformation(SongDTO song)
 {
     this.albumLabel.Content    = song.songTag.Album;
     this.artistLabel.Content   = song.songTag.Artist;
     this.durationLabel.Content = song.songTag.Duration.ToString(@"mm\:ss");
     this.thumbnailImage.Source = song.songTag.ThumbnailSource;
     this.titleLabel.Content    = song.songTag.Title;
     setTimeLabel(new TimeSpan(0));
 }
示例#24
0
        public List <SongDTO> getSongsOfPlayList(int playListID)
        {
            int            songID, time;
            string         title, lyrics, dateRelease, linkOpen, linkDownLoad, image;
            ArtistDTO      artis;
            int            artisID;
            string         artisName;
            SongDTO        song   = null;
            List <SongDTO> result = new List <SongDTO>();

            using (sqlConnection = new SqlConnection(connectionString))
            {
                try
                {
                    sqlConnection.Open();
                    using (command = new SqlCommand("" +
                                                    "Select distinct Songs.ID, Songs.title,Songs.lyrics,Songs.dateRelease,Songs.linkOpen,Songs.linkDownLoad,Songs.image,Songs.time,Artists.ID,Artists.name " +
                                                    "From Songs, Playlist_Songs, Playlists, Artists, Song_Album_Artist " +
                                                    "Where Songs.ID = Playlist_Songs.songID AND Playlist_Songs.PlaylistID = Playlists.ID " +
                                                    "AND Songs.ID = Song_Album_Artist.songID AND Song_Album_Artist.artistID = Artists.ID " +
                                                    "AND Playlists.ID = @playListID",
                                                    sqlConnection))
                        command.Parameters.AddWithValue("@playListID", playListID);
                    using (reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            //songs
                            songID       = reader.GetInt32(0);
                            title        = reader.GetString(1);
                            lyrics       = reader.GetString(2);
                            dateRelease  = reader.GetDateTime(3).ToString("yyyy-MM-dd");
                            linkOpen     = reader.GetString(4);
                            linkDownLoad = reader.GetString(5);
                            image        = reader.GetString(6);
                            time         = reader.GetInt32(7);
                            //artis
                            artisID   = reader.GetInt32(8);
                            artisName = reader.GetString(9);
                            artis     = new ArtistDTO(artisID, artisName);

                            song = new SongDTO(songID, title, lyrics, dateRelease, linkOpen, linkDownLoad, image, time, artis);
                            result.Add(song);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
                finally
                {
                    closeConnect();
                }
            }
            return(result);
        }
示例#25
0
        public Song Post(SongDTO value)
        {
            Song model = new Song()
            {
                Name  = value.Name,
                Style = value.Style
            };

            return(ISongRepository.Create(model));
        }
示例#26
0
 public Song(SongDTO SongDTO)
 {
     SongId      = SongDTO.SongId;
     Title       = SongDTO.Title;
     Artist      = SongDTO.Artist;
     Released    = SongDTO.Released;
     Genre       = SongDTO.Genre;
     MP3FilePath = SongDTO.MP3FilePath;
     SongBanner  = SongDTO.SongBanner;
 }
示例#27
0
        public async Task <IActionResult> Save([FromBody] SongDTO songDTO)
        {
            var operationResult = await songService.Save(songDTO);

            if (!operationResult.IsSuccess)
            {
                return(NotFound(operationResult.Message));
            }
            return(Ok(operationResult.Result));
        }
        public IActionResult Post([FromBody] SongDTO songDTOToAdd)
        {
            Song songToAdd = DTOToSong(songDTOToAdd);

            _context.Songs.Add(songToAdd);
            _context.SaveChanges();
            songDTOs = SongsConverter(_context.Songs.ToList());

            return(Created("api/MusicController", songDTOToAdd));
        }
示例#29
0
        public void Post(SongDTO value)
        {
            Song model = new Song()
            {
                title  = value.title,
                artist = value.artist,
                link   = value.link
            };

            iSongRepository.Create(model);
        }
        public IActionResult Delete(int id)
        {
            SongDTO songDTOToDelete = songDTOs.Where(song => song.Id == id).FirstOrDefault();
            Song    songToDelete    = DTOToSong(songDTOToDelete);

            _context.Remove(songToDelete);
            _context.SaveChanges();
            songDTOs = SongsConverter(_context.Songs.ToList());

            return(Ok(songDTOToDelete));
        }