public EntryViewModel GetEntryViewModel(int id) { var entry = Db.Entries.Single(en => en.Id == id); var vm = EntryViewModel.FromEntry(entry); vm.Tags = new List <string>() { "Eking", "Hero", "News" }; vm.BreadCrumbGroups = new List <GroupViewModel>(); var g = entry.Group; while (g != null) { vm.BreadCrumbGroups.Insert(0, new GroupViewModel { Id = g.Id, Name = g.Name }); g = g.Parent; } vm.InGroupEntries = new List <EntryViewModel>(); vm.RelatedEntries = new List <EntryViewModel>(); if (entry.Group == null) { return(vm); } foreach (var en in entry.Group.Entries.Take(5)) { vm.InGroupEntries.Add(new EntryViewModel { Id = en.Id, Title = en.Title }); vm.RelatedEntries.Add(new EntryViewModel { Id = en.Id, Title = en.Title }); } return(vm); }
public static EntryViewModel FromEntry(Entry entry) { var vm = new EntryViewModel { Content = entry.Content, Title = entry.Title, PostedDate = entry.Date == null ? DateTime.MinValue : (DateTime)entry.Date, ImageUrl = entry.ImageUrl, RelatedEntries = new List <EntryViewModel> { new EntryViewModel { Title = "Ref1" }, new EntryViewModel { Title = "Ref2" } }, PostMan = "Hero", RenderType = entry.ViewType, Id = entry.Id, Desc = entry.Description, SourceText = entry.EntrySource == null || entry.EntrySource.Source == null ? null : entry.EntrySource.Source.Name, SourceUrl = entry.EntrySource == null ? null : entry.EntrySource.Url, GroupName = entry.Group == null ? null : entry.Group.Name }; if (vm.RenderType == null) { vm.RenderType = "2x4"; } var sp = vm.RenderType.Split('x'); vm.W = int.Parse(sp[0]); vm.H = int.Parse(sp[1]); return(vm); }
public PartialViewResult EntryContentView(Entry entry) { return(PartialView(EntryViewModel.FromEntry(entry))); }
public static EntryViewModel FromEntry(Entry entry) { var vm = new EntryViewModel { Content = entry.Content, Title = entry.Title, PostedDate = entry.Date == null ? DateTime.MinValue : (DateTime)entry.Date, ImageUrl = entry.ImageUrl, RelatedEntries = new List<EntryViewModel> { new EntryViewModel { Title = "Ref1" }, new EntryViewModel { Title = "Ref2" } }, PostMan = "Hero", RenderType = entry.ViewType, Id = entry.Id, Desc = entry.Description, SourceText = entry.EntrySource == null || entry.EntrySource.Source == null ? null : entry.EntrySource.Source.Name, SourceUrl = entry.EntrySource == null ? null : entry.EntrySource.Url, GroupName = entry.Group == null ? null : entry.Group.Name }; if (vm.RenderType == null) vm.RenderType = "2x4"; var sp = vm.RenderType.Split('x'); vm.W = int.Parse(sp[0]); vm.H = int.Parse(sp[1]); return vm; }