Пример #1
0
        public ActionResult Index()
        {
            var db        = new BlogDb(_connectionString);
            var viewModel = new BlogsIndexViewModel
            {
                Posts = db.GetLastFive()
            };

            foreach (Post p in viewModel.Posts)
            {
                p.Text = StripTagsRegex(p.Text).Substring(0, 300) + "...";
            }
            return(View(viewModel));
        }
Пример #2
0
        public IActionResult Index(int userId, DateTime?dateFrom, DateTime?dateTo)
        {
            if (TempData != null)
            {
                return(null);
            }
            else
            {
                BlogsIndexViewModel viewModel = new BlogsIndexViewModel();

                viewModel.UserId = userId;
                viewModel.Rows   = db.Blogs.Where(x => x.UserId == userId).Select(x => new BlogsIndexViewModel.Row()
                {
                    BlogId             = x.Id,
                    PublishingDateTime = x.DateTime,
                    Summary            = x.Summary,
                    Title = x.Title
                }).ToList();

                return(PartialView(viewModel));
            }
        }