public async Task <ArtistResponse> AddArtistAsync(AddArtistRequest request)
        {
            var item   = _artistMapper.Map(request);
            var result = _artistRepository.Add(item);

            await _artistRepository.UnitOfWork.SaveChangesAsync();

            return(_artistMapper.Map(result));
        }
Example #2
0
        public async Task <ArtistResponse> GetArtistAsync(GetArtistRequest request)
        {
            if (request?.Id == null)
            {
                throw new ArgumentNullException();
            }
            var result = await _artistRepository.GetAsync(request.Id);

            return(result == null ? null : _artistMapper.Map(result));
        }
Example #3
0
        public async Task <ArtistResponse> AddArtistAsync(AddArtistRequest request)
        {
            Artist item = new Artist
            {
                ArtistName = request.ArtistName
            };

            Artist result = _artistRespository.Add(item);
            await _artistRespository.UnitOfWork.SaveChangesAsync();

            return(_artistMapper.Map(result));
        }
        public ItemResponse Map(Item request)
        {
            // Null checking
            if (request == null)
            {
                return(null);
            }
            // Mapping response
            var itemResponse = new ItemResponse
            {
                Id             = request.Id,
                Name           = request.Name,
                Description    = request.Description,
                LabelName      = request.LabelName,
                PictureUri     = request.PictureUri,
                ReleaseDate    = request.ReleaseDate,
                AvailableStock = request.AvailableStock,
                Genre          = _genreMapper.Map(request.Genre),
                GenreId        = request.GenreId,
                Artist         = _artistMapper.Map(request.Artist),
                ArtistId       = request.ArtistId,
                Format         = request.Format
            };

            if (request.Price != null)
            {
                itemResponse.Price = new Price {
                    Amount = request.Price.Amount, Currency = request.Price.Currency
                }
            }
            ;

            return(itemResponse);
        }
    }
Example #5
0
        public ItemResponse Map(Item request)
        {
            if (request == null)
            {
                return(null);
            }

            var response = new ItemResponse
            {
                Id             = request.Id,
                Name           = request.Name,
                Description    = request.Description,
                LabelName      = request.LabelName,
                PictureUri     = request.PictureUri,
                ReleaseDate    = request.ReleaseDate,
                Format         = request.Format,
                AvailableStock = request.AvailableStock,
                GenreId        = request.GenreId,
                Genre          = _genreMapper.Map(request.Genre),
                ArtistId       = request.ArtistId,
                Artist         = _artistMapper.Map(request.Artist),
            };

            if (request.Price != null)
            {
                response.Price = new PriceResponse {
                    Currency = request.Price.Currency, Amount = request.Price.Amount
                };
            }

            return(response);
        }
Example #6
0
    public ItemResponse Map(Item item)
    {
        if (item == null)
        {
            return(null);
        }

        var response = new ItemResponse
        {
            Id             = item.Id,
            Name           = item.Name,
            Description    = item.Description,
            LabelName      = item.LabelName,
            PictureUri     = item.PictureUri,
            ReleaseDate    = item.ReleaseDate,
            Format         = item.Format,
            AvailableStock = item.AvailableStock,
            GenreId        = item.GenreId,
            Genre          = _genreMapper.Map(item.Genre),
            ArtistId       = item.ArtistId,
            Artist         = _artistMapper.Map(item.Artist)
        };

        if (item.Price != null)
        {
            response.Price = new PriceResponse
            {
                Amount   = item.Price.Amount,
                Currency = item.Price.Currency
            };
        }

        return(response);
    }
Example #7
0
        public Track Map(S.ITrack track, SpotifyMusicProvider musicProvider, string user, bool mapAlbum = false, bool mapArtists = false)
        {
            string trackLink   = track.GetLinkString();
            var    trackResult = new Track
            {
                Link                 = trackLink,
                Name                 = track.Name,
                IsAvailable          = track.IsAvailable,
                Duration             = track.Duration,
                DurationMilliseconds = (long)track.Duration.TotalMilliseconds,
                MusicProvider        = musicProvider.Descriptor,
                ExternalLink         = new Uri(musicProvider.ExternalLinkBaseUrl, "/track/" + trackLink)
            };

            if (mapAlbum && track.Album != null)
            {
                trackResult.Album = albumMapper.Map(track.Album, musicProvider);
            }
            if (mapArtists && track.Artists != null)
            {
                trackResult.Artists = track.Artists.Select(t => artistMapper.Map(t, musicProvider)).ToArray();
            }

            //We want to set whether the track is already queued
            if (alreadyQueuedHelper != null)
            {
                trackResult = alreadyQueuedHelper.ResetAlreadyQueued((trackResult), user);
            }
            return(trackResult);
        }
Example #8
0
        public Album Map(S.IAlbum album, SpotifyMusicProvider musicProvider, bool mapArtist = false)
        {
            var albumLink   = album.GetLinkString();
            var albumResult = new Album
            {
                Link             = albumLink,
                Name             = album.Name,
                Year             = album.Year,
                ArtworkId        = album.CoverId,
                ArtworkUrlLarge  = ImageHelper.GetImageUrl(album.CoverId, 300),
                ArtworkUrlMedium = ImageHelper.GetImageUrl(album.CoverId, 120),
                ArtworkUrlSmall  = ImageHelper.GetImageUrl(album.CoverId, 60),
                IsAvailable      = album.IsAvailable,
                MusicProvider    = musicProvider.Descriptor,
                ExternalLink     = new Uri(musicProvider.ExternalLinkBaseUrl, "/album/" + albumLink)
            };

            if (mapArtist && album.Artist != null)
            {
                albumResult.Artist = artistMapper.Map(album.Artist, musicProvider);
            }
            return(albumResult);
        }