public SCTrack Convert(Track track)
        {
            if (track == null)
            {
                return(null);
            }

            return(new SCTrack
            {
                Id = track.Id,
                CreatedAt = dateTimeConverter.Convert(track.CreatedAt),
                UserId = track.UserId,
                User = userConverter.Convert(track.User),
                Title = track.Title,
                Permalink = track.Permalink,
                PermalinkUrl = track.PermalinkUrl,
                Uri = track.Uri,
                Sharing = track.Sharing.GetValue <SCSharing>(),
                EmbeddableBy = track.EmbeddableBy.GetValue <SCEmbeddableBy>(),
                Artwork = SCScalableEntity <SCArtworkFormat> .Create(track.Artwork),
                Description = track.Description,
                Label = userConverter.Convert(track.Label),
                Duration = TimeSpan.FromMilliseconds(track.Duration),
                Genre = track.Genre,
                TagList = tagListConverter.Convert(track.TagList),
                LabelId = track.LabelId,
                LabelName = track.LabelName,
                ReleaseNumber = track.Release,
                ReleaseDate = dateTimeConverter.ConvertReleaseDate(track.ReleaseYear, track.ReleaseMonth, track.ReleaseDay),
                Streamable = track.Streamable,
                Downloadable = track.Downloadable,
                State = track.State.GetValue <SCState>(),
                License = track.License.GetValue <SCLicense>(),
                TrackType = track.TrackType.GetValue <SCTrackType>(),
                WaveformUrl = track.WaveformUrl,
                DownloadUrl = track.DownloadUrl,
                StreamUrl = track.StreamUrl,
                VideoUrl = track.VideoUrl,
                Bpm = track.Bpm,
                Commentable = track.Commentable,
                Isrc = track.Isrc,
                KeySignature = track.KeySignature,
                CommentsCount = track.CommentsCount,
                DownloadCount = track.DownloadCount,
                PlaybackCount = track.PlaybackCount,
                FavoritingsCount = track.FavoritingsCount,
                OriginalFormat = track.OriginalFormat,
                OriginalContentSize = track.OriginalContentSize,
                CreatedWith = applicationConverter.Convert(track.CreatedWith),
                UserFavorite = track.UserFavorite,
                AttachmentUri = track.AttachmentUri,
                DownloadsRemaining = track.DownloadsRemaining,
                PurchaseUrl = track.PurchaseUrl,
                SecretToken = track.SecretToken,
                SecretUri = track.SecretUri,
                UserPlaybackCount = track.UserPlaybackCount
            });
        }
Esempio n. 2
0
        public SCUser UpdateUser(SCUser user)
        {
            if (!string.IsNullOrEmpty(userId) && user.Id != userId)
            {
                throw new SoundCloudApiException(string.Format("Context set for userId = {0}. Create new context for update another user.", userId));
            }

            var currentUser = GetInternalUser();
            var diff        = currentUser.GetDiff(userConverter.Convert(user));

            var parameters  = diff.ToDictionary(x => string.Format("user[{0}]", x.Key), x => x.Value);
            var updatedUser = soundCloudRawClient.Request <User>(prefix, string.Empty, HttpMethod.Put, parameters);

            return(userConverter.Convert(updatedUser));
        }
Esempio n. 3
0
        public async Task <IActionResult> Get([FromQuery] string facebookId, [FromQuery] Guid?userSystemId)
        {
            try
            {
                User user = null;
                if (facebookId == null)
                {
                    user = await _mediator.Send(new GetUserQuery(x => x.Id == userSystemId));
                }
                else if (userSystemId == null)
                {
                    user = await _mediator.Send(new GetUserQuery(x => x.FacebookId == facebookId));
                }

                if (user == null)
                {
                    return(NotFound());
                }
                return(Ok(_userConverter.Convert(user)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 4
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>   Gets an one. </summary>
        ///
        /// <param name="id">   The identifier. </param>
        ///
        /// <returns>   The one. </returns>
        ///-------------------------------------------------------------------------------------------------
        public async Task <IOrionUserDto> GetOne(long id)
        {
            //wire up db context, call to get task
            var task = await Task.FromResult(new OrionUser());

            var taskDto = _iudfConverter.Convert(task);

            return(taskDto);
        }
        public SCComment Convert(Comment comment)
        {
            if (comment == null)
            {
                return(null);
            }

            return(new SCComment
            {
                Id = comment.Id,
                Uri = comment.Uri,
                User = userConverter.Convert(comment.User),
                UserId = comment.UserId,
                CreatedAt = dateTimeConverter.SafeConvert(comment.CreatedAt),
                Body = comment.Body,
                Timestamp = TimeSpan.FromMilliseconds(comment.Timestamp),
                TrackId = comment.TrackId
            });
        }
Esempio n. 6
0
        public SCGroup Convert(Group @group)
        {
            if (@group == null)
            {
                return(null);
            }

            return(new SCGroup
            {
                Id = @group.Id,
                Artwork = SCScalableEntity <SCArtworkFormat> .Create(@group.ArtworkUrl),
                CreatedAt = dateTimeConverter.Convert(@group.CreatedAt),
                Uri = @group.Uri,
                Description = @group.Description,
                Permalink = @group.Permalink,
                PermalinkUrl = @group.PermalinkUrl,
                Creator = userConverter.Convert(@group.Creator),
                Name = @group.Name,
                ShortDescription = @group.Description
            });
        }
Esempio n. 7
0
        public SCPlaylist Convert(Playlist playlist)
        {
            if (playlist == null)
            {
                return(null);
            }

            return(new SCPlaylist
            {
                Id = playlist.Id,
                CreatedAt = dateTimeConverter.Convert(playlist.CreatedAt),
                UserId = playlist.UserId,
                User = userConverter.Convert(playlist.User),
                Title = playlist.Title,
                Permalink = playlist.Permalink,
                PermalinkUrl = playlist.PermalinkUrl,
                Uri = playlist.Uri,
                Sharing = playlist.Sharing.GetValue <SCSharing>(),
                EmbeddableBy = playlist.EmbeddableBy.GetValue <SCEmbeddableBy>(),
                PurchaseUrl = playlist.PurchaseUrl,
                Artwork = SCScalableEntity <SCArtworkFormat> .Create(playlist.ArtworkUrl),
                Description = playlist.Description,
                Label = userConverter.Convert(playlist.Label),
                LabelId = playlist.LabelId,
                LabelName = playlist.LabelName,
                Duration = TimeSpan.FromMilliseconds(playlist.Duration),
                Genre = playlist.Genre,
                TagList = tagListConverter.Convert(playlist.TagList),
                Release = playlist.Release,
                ReleaseDate = dateTimeConverter.ConvertReleaseDate(playlist.ReleaseYear, playlist.ReleaseMonth, playlist.ReleaseDay),
                Streamabale = playlist.Streamabale,
                Downloadable = playlist.Downloadable,
                Ean = playlist.Ean,
                PlaylistType = playlist.PlaylistType.GetValue <SCPlaylistType>(),
                License = playlist.License.GetValue <SCLicense>(),
                Tracks = playlist.Tracks.Select(trackConverter.Convert).ToArray(),
                Type = playlist.Type.GetValue <SCTrackType>()
            });
        }
Esempio n. 8
0
        public async Task <IActionResult> LoginAsync([FromBody] LoginInput input)
        {
            try
            {
                var response = await _accountService.LoginAsync(new LoginQuery(input.FacebookToken));

                return(Ok(new LoginQueryResource
                {
                    Token = response.Token,
                    User = _userConverter.Convert(response.User)
                }));
            }
            catch (RemoteEntityNotFoundException ex)
            {
                _logger.LogInformation(ex.Message);
                return(Unauthorized(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex);
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 9
0
        public SCUser GetFavoriter(string favoriterId)
        {
            var user = soundCloudRawClient.Request <User>(prefix, string.Format("favoriters/{0}", favoriterId), HttpMethod.Get);

            return(userConverter.Convert(user));
        }
Esempio n. 10
0
        public SCUser GetUser(string url)
        {
            var user = ResolveUrl <User>(url);

            return(userConverter.Convert(user));
        }