Ejemplo n.º 1
0
        public void Load(MixContract mix, bool censor)
        {
            this.IsExplicit = mix.IsExplicit && censor;
            this.MixName    = censor ? Censorship.Censor(mix.Name) : mix.Name;
            var lines =
                mix.Description.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(t => t.Trim())
                .Where(t => !string.IsNullOrWhiteSpace(t));

            this.Description   = censor ? Censorship.Censor(string.Join(Environment.NewLine, lines)) : string.Join(Environment.NewLine, lines);
            this.ThumbnailUrl  = this.IsExplicit ? this.AddQuery(mix.Cover.ThumbnailUrl, "nsfw") : mix.Cover.ThumbnailUrl;
            this.ImageUrl      = this.IsExplicit ? this.AddQuery(mix.Cover.OriginalUrl, "nsfw") : mix.Cover.OriginalUrl;
            this.TileTitle     = this.MixName.Replace(" ", Environment.NewLine);
            this.MixId         = mix.Id;
            this.NavigationUrl = PageUrl.Play(this.MixId, false, this.MixName);


            this.TrackCount = mix.TrackCount;
            var duration = TimeSpan.FromSeconds(mix.DurationSeconds);

            this.TotalDuration = "(" + duration.ToFormattedString() + ")";
            if (mix.RestUrl != null)
            {
                this.LinkUrl = new Uri(mix.RestUrl, UriKind.RelativeOrAbsolute);
            }

            this.Liked              = mix.Liked;
            this.CreatedBy          = mix.User.Name;
            this.CreatedByAvatarUrl = new Uri(mix.User.Avatar.ImageUrl, UriKind.RelativeOrAbsolute);
            this.Created            = mix.Created.ParseToLocalDateTimeEnsurePast();
            this.PlaysCount         = mix.PlaysCount;
            this.LikesCount         = mix.LikesCount;
            this.Tags = mix.Tags;
        }
Ejemplo n.º 2
0
        public void Load(ReviewContract review, bool censor)
        {
            if (review.User != null)
            {
                this.UserName      = review.User.Name;
                this.AvatarUrl     = Avatar.GetImageUrl(review.User.Avatar);
                this.NavigationUrl = PageUrl.UserProfile(review.User.Id, review.User.Name);
            }

            var text = Html.ConvertToPlainText(review.Body).Trim();

            this.Body    = censor ? Censorship.Censor(text) : text;
            this.Created = review.Created.ParseToLocalDateTimeEnsurePast();
            DateTimeOffset createdDate;

            if (DateTimeOffset.TryParse(review.Created, out createdDate))
            {
                this.Created = createdDate.ToLocalTime().DateTime;
            }
            else
            {
                this.Created = DateTime.Now.AddSeconds(-1);
            }

            if (this.Created > DateTime.Now)
            {
                this.Created = DateTime.Now.AddSeconds(-1);
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="userContract">
        /// </param>
        private void LoadUserProfile(UserContract userContract)
        {
            this.AvatarImageUrl = Avatar.GetLargeImageUrl(userContract.Avatar);
            this.Location       = userContract.Location;
            var text = Html.ConvertToPlainText(userContract.BioHtml).Trim();

            this.BioHtml  = this.censor ? Censorship.Censor(text) : text;
            this.UserName = userContract.Name;
            this.IsCurrentUserFollowing = userContract.IsFollowed;
        }