示例#1
0
        public ActionResult Index(int id)
        {
            BlogDto blog = _service.GetBlogs().SingleOrDefault(b => b.BlogId == id);

            List<EntryViewModel> entries = new List<EntryViewModel>();
            EntryViewModels entryViewModels = new EntryViewModels();

            if (blog != null)
            {
                entries.AddRange(blog.Entries.Select(entry => new EntryViewModel
                {
                    EntryId = entry.EntryId,
                    Body = entry.Body,
                    Title = entry.Title,
                    Date = entry.Date
                }));

                entryViewModels = new EntryViewModels
                {
                    BlogId = blog.BlogId,
                    Entries = entries,
                    Author = blog.Author
                };
            }

            return View(entryViewModels);
        }