Пример #1
0
        // GET: Index
        public ActionResult Index()
        {
            ArticlesManager articlesManager = new ArticlesManager();
            var             articles        = articlesManager.GetData()
                                              .Select(item => new Article {
                ArticleName = item.ArticleName, ArticleText = item.ArticleText
            })
                                              .ToList();

            ViewBag.VoteType = "Vote";
            if (Request.HttpMethod == "POST")
            {
                ViewBag.VoteType = "Result";
                VotingManager votesManager = new VotingManager();
                var           genderValue  = Request.Form["gender"];
                if (genderValue == "Male")
                {
                    votesManager.AddMaleVote();
                }
                else if (genderValue == "Female")
                {
                    votesManager.AddFemaleVote();
                }
                Voting votes = votesManager.GetData();
                ViewBag.Female = votes.Female;
                ViewBag.Male   = votes.Male;
                return(View(articles));
            }
            return(View(articles));
        }