public void AddTrackToCD(int id, Track track) { var trackEntity = new Data.Entities.Track {Artist = track.Artist, Length = track.Length, Name = track.Name}; var cdEntity = _cdRepository.GetById(id); trackEntity.CD = cdEntity; cdEntity.Tracks.Add(trackEntity); _cdRepository.Save(cdEntity); }
public void AddTrackToCd(int id, Track track) { var cdEntity = _cdRepository.GetById(id); var trackEntity = new Data.Entities.Track { Artist = track.Artist, CD = cdEntity, Length = track.Length, Name = track.Name }; if (cdEntity.Tracks == null) { cdEntity.Tracks = new List<Data.Entities.Track>(); } cdEntity.Tracks.Add(trackEntity); _cdRepository.Save(cdEntity); }
public void Save(Track track) { var cdEntity = _cdRepository.GetById(track.CD.Id); var trackEntity = new Data.Entities.Track { Artist = track.Artist, Id = track.Id, Length = track.Length, Name = track.Name, CD = cdEntity }; _trackRepository.Save(trackEntity); }
public int Save(CD cd) { var cdEntity = MapCDViewModelToCDEntity(cd); if (cd.Tracks != null) { cdEntity.Tracks = new List<Data.Entities.Track>(); foreach (var trackModel in cd.Tracks) { var trackEntity = new Data.Entities.Track { Id = trackModel.Id, Artist = trackModel.Artist, CD = cdEntity, Length = trackModel.Length, Name = trackModel.Name }; cdEntity.Tracks.Add(trackEntity); } } return _cdRepository.Save(cdEntity); }