Beispiel #1
0
        public async Task <IEnumerable <TrackModel> > AddCollectionAsync(IEnumerable <TrackModel> model)
        {
            if (model == null)
            {
                return(null);
            }

            var dataModelList = new List <Track>();

            foreach (TrackModel trackModel in model)
            {
                var dataModel = await _trackRepository.AddAsync(_trackMapper.ConvertToDataModel(trackModel));

                dataModelList.Add(dataModel);
            }

            var modelList = new List <TrackModel>();

            foreach (Track track in dataModelList)
            {
                var trackModel = _trackMapper.ConvertToModel(track);
                modelList.Add(trackModel);
            }
            return(modelList);
        }
Beispiel #2
0
        public async Task <TrackViewModel> AddTrackAsync(TrackViewModel newTrackViewModel, CancellationToken ct = default(CancellationToken))
        {
            var track = new Track
            {
                TrackId      = newTrackViewModel.TrackId,
                Name         = newTrackViewModel.Name,
                AlbumId      = newTrackViewModel.AlbumId,
                MediaTypeId  = newTrackViewModel.MediaTypeId,
                GenreId      = newTrackViewModel.GenreId,
                Composer     = newTrackViewModel.Composer,
                Milliseconds = newTrackViewModel.Milliseconds,
                Bytes        = newTrackViewModel.Bytes,
                UnitPrice    = newTrackViewModel.UnitPrice
            };

            await _trackRepository.AddAsync(track, ct);

            newTrackViewModel.TrackId = track.TrackId;
            return(newTrackViewModel);
        }
Beispiel #3
0
        public async Task AddTrackAsync(Track track)
        {
            await _trackRepository.AddAsync(track);

            await _unitOfWork.CommitAsync();
        }