public void MapModel(PostItemModel post, int index) { this.MapModel(post); this.ParseReferences(); this.Index = index; }
private void AddModel(PostItemModel model, int index) { var vm = new PostItemViewModel(this); vm.MapModel(model, index); this.ArrangeReferences(vm); this.Posts.Add(vm); this._itemsByPostNumbers[vm.Number] = vm; }
public virtual void MapModel(PostItemModel post) { this.Number = post.Number; this.HasSubject = !string.IsNullOrEmpty(post.Subject); this.Subject = post.Subject; this.Comment = post.Comment; this.HasImage = !string.IsNullOrEmpty(post.ThumbnailUri); this.HasVideo = !string.IsNullOrEmpty(post.VideoHtml); if (this.HasImage) { this.ThumbnailUri = this._urlBuilder.BuildResourceUrl(this.BoardName, post.ThumbnailUri); this.AttachmentUri = this._urlBuilder.BuildResourceUrl(this.BoardName, post.ImageUri); this.AttachmentInfo = string.Format(Strings.DataFormat_Kb, post.ImageSize); if (this.AttachmentUri.EndsWith(".gif")) { this.AttachmentInfo += " gif"; } } else if (this.HasVideo) { string code = this._youtubeHelper.GetYouTubeCode(post.VideoHtml); if (code != null) { this.ThumbnailUri = this._youtubeHelper.GetThumbnailUrl(code); this.AttachmentUri = this._youtubeHelper.GetVideoUrl(code); this.AttachmentInfo = "YouTube"; } else { this.HasVideo = false; } } this.HasAttachment = this.HasImage || this.HasVideo; }