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 }
                };
            }
        }
        public ActionResult Index()
        {
            if (Session["UserId"] == null)
                return RedirectToAction("Index", "Home");

            using (var electionRepository = new ElectionRepository())
            using (var candidateRepository = new CandidateRepository())
            using (var voterRepository = new VoterRepository())
            {
                if (electionRepository.GetElectionByUserId((int)Session["UserId"]) == null)
                {
                    electionRepository.CreateElection(new Election
                    {
                        UserId = (int)Session["UserId"],
                        Name = "My Election"
                    });
                }

                var election = electionRepository.GetElectionByUserId((int)Session["UserId"]);

                var electionIndexModel = new ElectionIndexModel
                {
                    Setup = new ElectionSetupModel
                    {
                        Name = election.Name,
                        Status = election.Status,
                        MinVotes = election.MinVotes,
                        MaxVotes = election.MaxVotes,
                        NoVote = election.NoVote
                    },
                    Candidates = candidateRepository.GetCandidatesForElectionId(ElectionConductor.ElectionId((int)Session["UserId"])).OrderBy(x => x.Name).ToList(),
                    VotersCount = voterRepository.GetVotersForElectionId(ElectionConductor.ElectionId((int)Session["UserId"])).Count
                };

                return View(electionIndexModel);
            }
        }
        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");
        }