コード例 #1
0
ファイル: ElectionController.cs プロジェクト: jhhwilliams/ses
        public JsonResult AddVoter(string voterId)
        {
            using (var voterRepository = new VoterRepository())
            {
                var result = voterRepository.CreateVoter(new Voter { ElectionId = ElectionConductor.ElectionId((int)Session["UserId"]), IdentityNumber = voterId });

                return new JsonResult
                {
                    Data = new { isOk = result }
                };
            }
        }
コード例 #2
0
ファイル: ElectionController.cs プロジェクト: jhhwilliams/ses
        public ActionResult Index(HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                var voterRegisterFile = handleUploadedFile(file);

                using (var voterRepository = new VoterRepository())
                {
                    voterRepository.DeleteVotersForElectionId(ElectionConductor.ElectionId((int)Session["UserId"]));

                    foreach (var voter in voterRegisterFile.Voters)
                    {
                        voterRepository.CreateVoter(new Voter
                        {
                            ElectionId = ElectionConductor.ElectionId((int)Session["UserId"]),
                            IdentityNumber = voter.IdentityNumber
                        });
                    }
                }
            }
            return RedirectToAction("Index");
        }