Пример #1
0
        public ActionResult UpdatePoll(string poll)
        {
            var repoPoll   = new PublicPollRepository();
            var pollResult = repoPoll.GetPublicPoll();

            if (!string.IsNullOrEmpty(poll))
            {
                UpdateOption(ref pollResult, poll);
                repoPoll.UpdatePublicPoll(pollResult);
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        // GET: Main
        public ActionResult Index()
        {
            var repo = new ArticlesRepository();
            ArticleViewModel articlesViewModel = repo.GetArticles();

            ArticleViewModel articlesPreviewModel = new ArticleViewModel
            {
                ArticleItems = articlesViewModel.ArticleItems.Select(article =>
                                                                     new ArticleItem
                {
                    ArticleId    = article.ArticleId,
                    ArticleTitle = article.ArticleTitle,
                    Author       = article.Author,
                    Time         = article.Time,
                    ArticleBody  = article.ArticleBody.Substring(0, article.ArticleBody.IndexOf("/", StringComparison.Ordinal) + 2)
                }
                                                                     ).ToList()
            };

            var repoPoll = new PublicPollRepository();

            articlesPreviewModel.PublicPolls = repoPoll.GetPublicPoll();
            return(View(articlesPreviewModel));
        }