Esempio n. 1
0
        public ActionResult Archive(string year, string month)
        {
            BlogPostClient bpc = new BlogPostClient();

            if (!Regex.IsMatch(year, @"^\d{4}$") || !Regex.IsMatch(month, @"^\d{2}$"))
            {
                return(RedirectToAction("Index"));
            }
            DateTime        date      = Convert.ToDateTime(month + "/" + year);
            List <BlogPost> postsList = new List <BlogPost>(bpc.GetAllFromArchive(date));

            postsList.Sort((a, b) => DateTime.Compare(b.Date, a.Date));
            if (postsList.Count == 0)
            {
                ViewBag.Articles = null;
            }
            else
            {
                ViewBag.Year     = year;
                ViewBag.Month    = monthName(month);
                ViewBag.Articles = postsList;
            }
            return(View());
        }