Exemplo n.º 1
0
 public ActionResult Index(HomepageParameters homepageParameters)
 {
     using (_profilerWrapper.Step("View home page action"))
     {
         return View(_homepageViewModel.Build(homepageParameters));
     }
 }
Exemplo n.º 2
0
        public string BuildTitle(HomepageParameters homepageParameters)
        {
            var title = new StringBuilder();
            if (homepageParameters.Year > 0)
            {
                if (homepageParameters.Month > 0)
                {
                    title.Append(string.Concat(homepageParameters.Month.ToMonthName(), " "));
                }
                title.Append(homepageParameters.Year);

                if (!string.IsNullOrWhiteSpace(homepageParameters.Category) || !string.IsNullOrWhiteSpace(homepageParameters.Tag))
                {
                    title.Append(" - ");
                }
            }

            if (!string.IsNullOrWhiteSpace(homepageParameters.Category))
            {
                title.Append(homepageParameters.Category);

                if (!string.IsNullOrWhiteSpace(homepageParameters.Tag))
                {
                    title.Append(", ");
                }
            }

            if (!string.IsNullOrWhiteSpace(homepageParameters.Tag))
            {
                title.Append(string.Concat("tagged ", homepageParameters.Tag));
            }

            return title.ToString();
        }
Exemplo n.º 3
0
        public HomepageViewModel Build(HomepageParameters homepageParameters)
        {
            using (_profilerWrapper.Step("Build home page view model"))
            {
                var siteID = 1;
                var limit = DateTime.Now.Date.Add(new TimeSpan(-(365 * 5), 0, 0, 0));

                var title = _homepageTitleFactory.BuildTitle(homepageParameters);

                var tagCloud = _blogEntryRepository.GetTagCloud();

                return new HomepageViewModel(_blogEntryRepository.GetBlogEntries(new BlogQuery(homepageParameters)),
                                             title,
                                             _blogEntryRepository.GetArchive(),
                                             _tagCloudViewModelFactory.Build(tagCloud));

            }
        }
Exemplo n.º 4
0
        public BlogQuery(HomepageParameters homepageParameters)
        {
            Category = string.IsNullOrWhiteSpace(homepageParameters.Category) ? null : homepageParameters.Category;
            Tag = string.IsNullOrWhiteSpace(homepageParameters.Tag) ? null : homepageParameters.Tag;

            if(homepageParameters.Month > 0)
            {
                StartDate = new DateTime(homepageParameters.Year, homepageParameters.Month, 1);
                EndDate = StartDate.Value.AddMonths(1).AddSeconds(-1);
            }
            else if(homepageParameters.Year > 0)
            {
                StartDate = new DateTime(homepageParameters.Year, 1, 1);
                EndDate = StartDate.Value.AddYears(1).AddSeconds(-1);
            }
        }