Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
        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);
        }