コード例 #1
0
        public NewsListViewModel(News item)
        {
            Title = item.Title;
            Date = item.Date;
            Brief = item.Body.TruncateHtml(100, "...");
            Slug = item.Slug;

            if (item.Attachments.Any(a => a.Type == FileType.Image))
            {
                LogoUrl = ThumbnailService.GetThumbnailUrl(item.Attachments.First(f => f.Type == FileType.Image), 100, 100);
                LogoUrlWide = ThumbnailService.GetThumbnailUrl(item.Attachments.First(f => f.Type == FileType.Image), 320, 200);
            }
            else LogoUrl = "/images/default.png";
            Type = item.Type;
            switch (item.Type)
            {
                case NewsType.Gallery:
                    LogoClass = "fa-picture-o";
                    break;
                case NewsType.Quote:
                    LogoClass ="";
                    break;
                case NewsType.Video:
                    LogoClass ="fa-film";
                    break;
                default:
                    LogoClass = "fa-pencil";
                    break;

            }
        }
コード例 #2
0
 public NewsDetailsViewModel(News item)
 {
     Title = item.Title;
     Date = item.Date;
     if (item.Attachments.Any(f => f.Type == FileType.Image))
     {
         var logo = item.Attachments.First(f => f.Type == FileType.Image);
         LogoThumbnail = ThumbnailService.GetThumbnailUrl(logo, 600, 400);
         LogoUrl = ThumbnailService.GetRawFile(logo);
         Attachments = item.Attachments.Where(f=>f!=logo).Select(f => new FileViewModel(f)).ToList();
     }
     else
     {
         LogoUrl = LogoThumbnail = "/images/default.png";
         Attachments = new List<FileViewModel>();
     }
     Body = item.Body;
 }