예제 #1
0
        public void EditArtist(ArtistDTO artistDTO, List <int> albumIds)
        {
            if (artistDTO == null)
            {
                throw new ArgumentNullException("Artist service - EditArtist(...) artistDTO cannot be null");
            }

            using (var uow = UnitOfWorkProvider.Create())
            {
                var artist = artistRepository.GetByID(artistDTO.ID);
                Mapper.Map(artistDTO, artist);

                if (albumIds != null && albumIds.Any())
                {
                    var albums = albumRepository.GetByIDs(albumIds);
                    if (albums == null)
                    {
                        throw new NullReferenceException("Artist service - EditArtist(...) album cannot be null(could not be found)");
                    }

                    artist.Albums.RemoveAll(review => !albums.Contains(review));
                    artist.Albums.AddRange(
                        albums.Where(review => !artist.Albums.Contains(review)));
                }
                else
                {
                    artist.Albums.Clear();
                }

                artistRepository.Update(artist);
                uow.Commit();
            }
        }
예제 #2
0
        private void btUpdate_Click(object sender, EventArgs e)
        {
            string id    = txtID.Text;
            string name  = txtName.Text;
            string label = txtLabel.Text;

            if (addNew)
            {
                if (checkValidate())
                {
                    ArtistDTO albumDTO = new ArtistDTO(int.Parse(id), name, label, "defaultArtistIMG.jpg");
                    if (artistDAO.addArtist(albumDTO))
                    {
                        MessageBox.Show("Add new successfully");
                    }
                    else
                    {
                        MessageBox.Show("Add new failed");
                    }
                }
            }
            else
            {
                ArtistDTO albumDTO = new ArtistDTO(int.Parse(id), name, label, "defaultArtistIMG.jpg");
                if (artistDAO.updateArtist(albumDTO))
                {
                    MessageBox.Show("Update successfully");
                }
                else
                {
                    MessageBox.Show("Update failed");
                }
            }
            refreshUI();
        }
예제 #3
0
        public void CreateArtist(ArtistDTO artistDTO)
        {
            if (artistDTO == null)
            {
                throw new ArgumentNullException("Artist service - CreateArtist(...) artistDTO cannot be null");
            }

            Album  album;
            Artist artist = Mapper.Map <Artist>(artistDTO);

            using (var uow = UnitOfWorkProvider.Create())
            {
                if (artistDTO.AlbumIDs != null)
                {
                    foreach (int ID in artistDTO.AlbumIDs)
                    {
                        album = GetArtistAlbum(ID);

                        if (album == null)
                        {
                            throw new NullReferenceException("Artist service - CreateArtist(...) album cannot be null(could not be found)");
                        }

                        artist.Albums.Add(album);
                    }
                }

                artist.Creator = GetArtistCreator(artistDTO.CreatorID);

                artistRepository.Insert(artist);
                uow.Commit();
            }
        }
예제 #4
0
        public Boolean updateArtist(ArtistDTO dto)
        {
            Boolean check = false;

            using (sqlConnection = new SqlConnection(connectionString))
            {
                try
                {
                    sqlConnection.Open();
                    command = new SqlCommand("UPDATE Artists SET name = @name, label = @label " +
                                             "WHERE ID = @id", sqlConnection);
                    command.Parameters.AddWithValue("@id", dto.Id);
                    command.Parameters.AddWithValue("@name", dto.Name);
                    command.Parameters.AddWithValue("@label", dto.Label);
                    check = command.ExecuteNonQuery() > 0;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
                finally
                {
                    closeConnect();
                }
            }
            return(check);
        }
예제 #5
0
        public async Task <ArtistDTO> InsertArtistAsync(Artist artist)
        {
            ArtistDTO newArtist = new ArtistDTO();

            try
            {
                artist.Id = Guid.NewGuid();
                await _dbContext.Artists.AddAsync(artist);

                var save = await _dbContext.SaveChangesAsync();

                if (save == 1)
                {
                    newArtist.NameArtist = artist.NameArtist;
                    newArtist.Country    = artist.Country;
                    newArtist.Gender     = artist.Gender;
                    newArtist.Id         = artist.Id;
                }
                else
                {
                    newArtist = null;
                }
            }
            catch
            {
                newArtist = null;
            }
            return(newArtist);
        }
예제 #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);
 }
예제 #7
0
        public ICollection <ArtistDTO> MapArtists(IEnumerable <Artist> artists)
        {
            ICollection <ArtistDTO> artistDTOs = new LinkedList <ArtistDTO>();
            ArtistDTO artistDTO = null;

            foreach (var artist in artists)
            {
                artistDTO = new ArtistDTO(artist.Id, artist.Name, artist.Description, artist.Country, artist.YearActive);

                if (artist.Tracks.Count > 0)
                {
                    foreach (var track in artist.Tracks)
                    {
                        artistDTO.Tracks.Add(new TrackDetailDTO(track.Track.Title, track.Track.Duration, track.Track.ReleaseDate));
                    }
                }

                if (artist.Albums.Count > 0)
                {
                    foreach (var album in artist.Albums)
                    {
                        artistDTO.Albums.Add(new AlbumDetailDTO(album.Album.Title, album.Album.RecordLabel, album.Album.ReleaseDate));
                    }
                }

                artistDTOs.Add(artistDTO);
            }

            return(artistDTOs);
        }
예제 #8
0
        public Boolean addArtist(ArtistDTO dto)
        {
            Boolean check = false;

            using (sqlConnection = new SqlConnection(connectionString))
            {
                try
                {
                    sqlConnection.Open();
                    using (command = new SqlCommand("Insert into " +
                                                    " Artists(ID,name,label,image) " +
                                                    " Values (@ID, @name,@label,@image)", sqlConnection))
                    {
                        command.Parameters.AddWithValue("@ID", dto.Id);
                        command.Parameters.AddWithValue("@name", dto.Name);
                        command.Parameters.AddWithValue("@label", dto.Label);
                        command.Parameters.AddWithValue("@image", dto.Image);
                        check = command.ExecuteNonQuery() > 0;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
                finally
                {
                    closeConnect();
                }
            }
            return(check);
        }
예제 #9
0
        public async Task <IActionResult> PutArtist(int id, ArtistDTO artist)
        {
            if (ModelState.IsValid)
            {
                if (id != artist.Id)
                {
                    return(BadRequest());
                }

                try
                {
                    await this._artistService.UpdateAsync(id, artist);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await ArtistExistsAsync(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        return(BadRequest());
                    }
                }

                return(NoContent());
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #10
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);
        }
예제 #11
0
        public async Task DeleteArtist(ArtistDTO artist)
        {
            var NewMusic = _mapper.Map <ArtistDTO, Artist>(artist);

            _unitOfWork.Artists.Remove(NewMusic);
            await _unitOfWork.CommitAsync();
        }
예제 #12
0
        public void Update(ArtistDTO artistDTO)
        {
            var artist = artistRepository.GetDetail(x => x.Id == artistDTO.Id);

            Mapper.Map <ArtistDTO, Artist>(artistDTO, artist);
            artistRepository.SaveChanges();
        }
        public void RegisterArtist(RegisterArtistCommand command)
        {
            if (KeyAlreadyRegisteredOnDifferentMacAddress(command.Key, command.MacAddress))
            {
                throw new Exception($"Key {command.Key} already used by different Artist");
            }

            var ensemble = _ensembles.GetEnsemble(command.EnsembleKey);

            if (ensemble == null)
            {
                throw new ArgumentException($"Ensemble not found: {command.EnsembleKey}");
            }

            if (command.RegistrationKey != ensemble.RegistrationKey)
            {
                throw new Exception($"Registration key does not match that of the Ensemble");
            }

            var artist = new ArtistDTO
            {
                Key          = command.Key,
                ComputerName = command.ComputerName,
                MacAddress   = command.MacAddress
            };

            _artists.CreateArtist(artist);
            _artists.BindArtistToEnsemble(artist, ensemble);
        }
예제 #14
0
        public List <ArtistDTO> GetArtists()
        {
            List <ArtistDTO> artists          = new List <ArtistDTO>();
            string           connectionString = ConfigurationManager.ConnectionStrings["GramophoneDB"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "select ArtistID,Name from [Artist]";
                    cmd.Connection  = connection;
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        ArtistDTO artist = new ArtistDTO();
                        artist.ArtistID = Convert.ToInt32(reader["ArtistID"].ToString());
                        artist.Name     = reader["Name"].ToString();
                        artists.Add(artist);
                    }
                }
                connection.Close();
            }
            return(artists);
        }
예제 #15
0
        public IActionResult GetArtist(string id)
        {
            ArtistDTO a = new ArtistDTO();

            a.Artist = _context.Artist.Where((a => a.IdArtist == int.Parse(id))).FirstOrDefault();
            if (a.Artist == null)
            {
                return(NotFound("Brak artysty"));
            }

            var tmp = _context.Artist_Event.Where((a => a.IdArtist == int.Parse(id)));

            foreach (var aE in tmp)
            {
                var x = _context.Event.Where(e => e.IdEvent == aE.IdEvent).FirstOrDefault();
                if (x == null)
                {
                    continue;
                }
                if (!a.Events.Contains(x))
                {
                    a.Events.Add(h);
                }
            }

            a.Events = a.Events.OrderByDescending(e => e.StartDate).ToList();
            return(Ok(a));
        }
예제 #16
0
        //voegt de artiest toe aan de lijst
        public void AddArtist(string artistname, string artistid)
        {
            var dto = new ArtistDTO {
                name = artistname, id = artistid
            };

            artistService.AddArtistToList(dto);
        }
예제 #17
0
 public void CreateArtist(ArtistDTO artistDTO)
 {
     using (var transaction = ArtistRepository.UnitOfWork.BeginTransaction(2))
     {
         ArtistRepository.Add(ArtistFactory.CreateArtist(artistDTO.Name, artistDTO.Description, artistDTO.Country, artistDTO.Year));
         transaction.Commit();
     }
 }
예제 #18
0
 public static ArtistViewModel ToViewModel(this ArtistDTO artistDTO)
 {
     return(new ArtistViewModel()
     {
         Name = artistDTO.Name,
         Tracklist = artistDTO.Tracklist,
         Type = artistDTO.Type
     });
 }
예제 #19
0
        public List <ArtistDTO> GetArtists(ArtistsPageFilter filter)
        {
            //var filterArtists = Builders<Artist>.Filter.ElemMatch(x => x.Name, Builders<Album>.Filter.AnyIn(x => x.SongsIds, songsIds));
            //var filterArtists = Builders<Artist>.Filter.Regex(x => x.Name,".*"+ filter.SearchText+ ".*");

            var filterArtists = Builders <Artist> .Filter.Regex(x => x.Name, new BsonRegularExpression($".*{filter.SearchText}.*"));


            var userLibSongIds = libraryDbList.Find(l => l.Id == filter.LibraryId).FirstOrDefault().SongsIds;

            var artists = artistsDbList.Find(filterArtists).Skip(filter.PageIndex * filter.PageSize)
                          .Limit(filter.PageSize).ToList();

            var allSongsIds = artists.SelectMany(a => a.Albums.SelectMany(aa => aa.SongsIds));


            var songsFilter = Builders <Song> .Filter.In(x => x.Id, allSongsIds);

            var songs = songsDbList.Find(songsFilter).ToList();

            var artistsDTOs = new List <ArtistDTO>();

            foreach (var artist in artists)
            {
                var artistDTO = new ArtistDTO();

                artistDTO.Id         = artistDTO.Id;
                artistDTO.Name       = artist.Name;
                artistDTO.UrlPicture = artist.UrlPicture;
                artistDTO.Albums     = new List <AlbumDTO>();

                foreach (var album in artist.Albums)
                {
                    var albumDTO = new AlbumDTO();
                    albumDTO.Id         = album.Id;
                    albumDTO.Name       = album.Name;
                    albumDTO.UrlPicture = album.UrlPicture;
                    albumDTO.Songs      = new List <SongSimpleDTO>();

                    foreach (var songId in album.SongsIds)
                    {
                        var song    = songs.FirstOrDefault(s => s.Id == songId);
                        var songDTO = new SongSimpleDTO()
                        {
                            Id          = song.Id,
                            Name        = song.Name,
                            Url         = song.Url,
                            IsInLibrary = userLibSongIds.Contains(song.Id)
                        };
                        albumDTO.Songs.Add(songDTO);
                    }
                    artistDTO.Albums.Add(albumDTO);
                }
                artistsDTOs.Add(artistDTO);
            }
            return(artistsDTOs);
        }
예제 #20
0
        public ArtistDTO GetById(int id)
        {
            string  commandText = "Select * FROM Artist WHERE ArtistID=" + id;
            DataSet dataSet     = SelectEntity(commandText);

            ArtistDTO artist = EntityHelper.CreateEntityFromDataRow <ArtistDTO>(dataSet.Tables[0].Rows[0]);

            return(artist);
        }
예제 #21
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);
        }
예제 #22
0
        public async Task <ArtistDTO> UpdateArtist(ArtistDTO artistToBeUpdated, SaveArtistDTO artist)
        {
            var newArtist      = _mapper.Map <SaveArtistDTO, ArtistDTO>(artist);
            var newArtistBasic = _mapper.Map <ArtistDTO, Artist>(artistToBeUpdated);

            newArtistBasic.Name = newArtist.Name;
            await _unitOfWork.CommitAsync();

            return(await GetArtistById(newArtistBasic.Id));
        }
예제 #23
0
        public Artist Post(ArtistDTO value)
        {
            Artist model = new Artist()
            {
                Name        = value.Name,
                Nationality = value.Nationality
            };

            return(IArtistRepository.Create(model));
        }
예제 #24
0
 public ActionResult AddArtist(int?id)
 {
     if (id.HasValue)
     {
         ArtistService artistService = new ArtistService();
         ArtistDTO     artist        = artistService.GetById(id.Value);
         return(View(artist));
     }
     return(View());
 }
예제 #25
0
 public static Artist ToEntity(this ArtistDTO artistDTO)
 {
     return(new Artist()
     {
         Id = artistDTO.Id,
         Name = artistDTO.Name,
         Tracklist = artistDTO.Tracklist,
         Type = artistDTO.Type
     });
 }
예제 #26
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            ArtistDTO artistDTO = ((FrameworkElement)sender).DataContext as ArtistDTO;
            Artist    artist    = new Artist();

            //Userbll.UpdateUser(, this);
            this.Show();
            ////Update update = new Update(List parentWindow, ResearchDTO research);
            //update.Show();
        }
예제 #27
0
        //een artiest toeveogen aan de lijst van artiesten
        public ArtistDTO AddArtistToList(ArtistDTO artistdto)
        {
            Artist artist = new Artist
            {
                Artistid   = artistdto.id,
                ArtistName = artistdto.name
            };

            Artists.Add(artist);
            return(artistdto);
        }
예제 #28
0
 public async Task <ArtistDTO> GetByNameAsync(string name)
 {
     try
     {
         ArtistDTO artist = this._mapper.Map <ArtistDTO>(await this._artistRepository.GetByNameAsync(name));
         return(artist);
     }
     catch (Exception exception)
     {
         return(null);
     }
 }
예제 #29
0
 public async Task <ArtistDTO> GetAsync(int id)
 {
     try
     {
         ArtistDTO artist = this._mapper.Map <ArtistDTO>(await this._artistRepository.GetAsync(id));
         return(artist);
     }
     catch (Exception exception)
     {
         return(null);
     }
 }
        public ArtistUpdate(List parentWindow, ArtistDTO artist)
        {
            InitializeComponent();

            artistDTO      = artist;
            myParentWindow = parentWindow;

            txtName.Text        = artist.Name;
            txtBrithPlace.Text  = artist.BirthPlace;
            txtAge.Text         = artist.Age;
            txtStyleOfWork.Text = artist.StyleOfWork;
        }