예제 #1
0
        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
        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");
        }