/// <summary>
        /// The map from.
        /// </summary>
        /// <param name="blog">
        /// The blog input.
        /// </param>
        /// <returns>
        /// The mapped archive section view model.
        /// </returns>
        public ArchiveSectionViewModel MapFrom(Blog blog)
        {
            var archiveSectionViewModel = new ArchiveSectionViewModel();

            var orderedArchives = new List<ArchiveYearViewModel>();

            blog.CreationDate.ToPastYears().ForEach(
                pastYear =>
                    {
                        var archiveYeaViewModel = this.archiveYearViewModelMapper.MapFrom(blog, pastYear);
                        if (archiveYeaViewModel != null)
                        {
                            orderedArchives.Add(archiveYeaViewModel);
                        }
                    });

            archiveSectionViewModel.Archives = orderedArchives.
                OrderByDescending(x => x.ArchiveYear, new IntYearDateTimeComparer());

            return archiveSectionViewModel;
        }
        /// <summary>
        /// The map from.
        /// </summary>
        /// <param name="blog">
        /// The blog to map from.
        /// </param>
        /// <param name="blogPost">
        /// The blog Post.
        /// </param>
        /// <returns>
        /// The blog post page view model.
        /// </returns>
        public BlogPostPageViewModel MapFrom(Blog blog, BlogPost blogPost, Tag tags)
        {
            var blogPostPageViewModel = new BlogPostPageViewModel
                {
                    ShowEditLink = blog.Author.Equals(this.identityService.GetCurrentUser()),
                    BlogUrl = blog.Url,
                    Body = blogPost.Body,
                    Author = blog.Author.Username,
                    PostDate = blogPost.PostDate.ToString("dd MMMM yyyy"),
                    Form = this.blogPostFormViewModelMapper.MapFrom(blogPost),
                    Comments = blogPost.Comments.MapAllUsing(this.blogPostCommentPageViewModelMapper).ToList(),
                    ArchiveSectionViewModel = this.archiveSectionViewModelMapper.MapFrom(blog),
                    Title = blogPost.Title,
                    Url = blogPost.Url,
                };

            blogPost.Tags.ForEach(x => blogPostPageViewModel.AssignedTags.Add("{0}-{1}".FormatWith(x.Name, x.Id)));

            blogPostPageViewModel.Tags = tags;
            return blogPostPageViewModel;
        }
Exemplo n.º 3
0
 public ActionResult About(Blog model)
 {
     var cmd = new Messages.Command {Id = Guid.NewGuid()};
     Bus.Send(cmd);
     return View(model);
 }
Exemplo n.º 4
0
 public ActionResult About()
 {
     ViewBag.Message = "Your app description page.";
     var model = new ViewModels.Blog();
     return View(model);
 }