예제 #1
0
        public List <ElectionModel> listMember()
        {
            List <ElectionModel> mod = new List <ElectionModel>();
            string query             = "SELECT * FROM public.election";

            try
            {
                con.Open();
                cmd = new NpgsqlCommand(query, con);
                NpgsqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        ElectionModel model = new ElectionModel();
                        model.e_id       = Convert.ToInt32(dr["e_id"]);
                        model.e_name     = dr["e_name"].ToString();
                        model.e_village  = dr["e_village"].ToString();
                        model.e_dist     = dr["e_dist"].ToString();
                        model.e_postcode = Convert.ToInt32(dr["e_postcode"]);
                        mod.Add(model);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(mod);
        }
예제 #2
0
        public List <ElectionModel> ReadData()
        {
            var listData = new List <ElectionModel>();

            using (var reader = new StreamReader(FilePath))
            {
                while (!reader.EndOfStream)
                {
                    var dataFromReader   = reader.ReadLine();
                    var listDataFromFile = dataFromReader.Split(',');
                    int.TryParse(listDataFromFile[5], out int score);
                    var data = new ElectionModel
                    {
                        Id        = Guid.NewGuid().ToString(),
                        Name      = listDataFromFile[2],
                        NameParty = listDataFromFile[4],
                        No        = listDataFromFile[3],
                        NameArea  = $"{listDataFromFile[0]}{listDataFromFile[1]}",
                        Score     = score
                    };
                    listData.Add(data);
                    System.Console.WriteLine(dataFromReader);
                }
            }
            return(listData);
        }
예제 #3
0
        public int update(ElectionModel model)
        {
            string query = "UPDATE public.election SET e_name=@e_name,e_village=@e_village,e_dist=@e_dist,e_postcode=@e_postcode where e_id=@e_id";
            int    i     = 0;

            try
            {
                con.Open();
                cmd = new NpgsqlCommand(query, con);
                cmd.Parameters.AddWithValue("@e_name", model.e_name);
                cmd.Parameters.AddWithValue("@e_village", model.e_village);
                cmd.Parameters.AddWithValue("@e_dist", model.e_dist);
                cmd.Parameters.AddWithValue("@e_postcode", model.e_postcode);
                cmd.Parameters.AddWithValue("@e_id", model.e_id);
                i = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(i);
        }
예제 #4
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                grdBallot.Visibility             = Visibility.Hidden;
                btnReset.Visibility              = Visibility.Collapsed;
                btnNext.Visibility               = Visibility.Collapsed;
                bdrLoadingMaintenance.Visibility = Visibility.Visible;

                _currentElection = await _electionService.GetCurrentElectionAsync();

                await SetBallotAsync(_voter);

                grdBallot.Visibility             = Visibility.Visible;
                btnReset.Visibility              = Visibility.Visible;
                btnNext.Visibility               = Visibility.Visible;
                bdrLoadingMaintenance.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);

                MessageBox.Show(ex.GetBaseException().Message, "PROGRAM ERROR: " + ex.Source, MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
예제 #5
0
        //private void lblVoterID_Click(object sender, EventArgs e)
        //{
        //    G.WaitLang(this);

        //    var window = new VotersListWindow();
        //    var helper = new WindowInteropHelper(window);
        //    helper.Owner = Handle;

        //    G.EndWait(this);

        //    window.ShowDialog();

        //    G.WaitLang(this);

        //    var voter = window.GetNewData();
        //    G.EndWait(this);

        //    if (voter == null) return;

        //    lblName.Visible = true;
        //    lblStrand.Visible = true;

        //    lblVoterID.Text = voter.VoterID;
        //    lblVoterID.Tag = voter.ID;
        //    lblName.Text = voter.FullName;
        //    lblStrand.Text = voter.GradeStrand;

        //    if (lblName.Width > 255)
        //    {
        //        lblName.Width = 255;
        //        lblName.AutoSize = false;

        //        ttpCandidate.SetToolTip(lblName, voter.FullName);
        //    }
        //    else
        //    {
        //        ttpCandidate.SetToolTip(lblName, null);
        //    }

        //    txtAlias.Text = voter.FirstName;
        //    txtAlias.Focus();
        //    txtAlias.SelectAll();
        //}

        private async void CandidateForm_Load(object sender, EventArgs e)
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            dtBirthdate.MaxDate = DateTime.Today;

            if (EditingCandidate == null)
            {
                lblTitle.Text = "Add Candidate";
                btnAdd.Text   = "ADD";

                await LoadPositionsAsync();

                cmbPosition.SelectedIndex = -1;
            }
            else
            {
                var party = await _partyService.GetPartyAsync(EditingCandidate.PartyId);

                SetParty(party);

                lblTitle.Text = "Edit Candidate";

                txtFirstName.Text   = EditingCandidate.FirstName;
                txtMiddleName.Text  = EditingCandidate.MiddleName;
                txtLastName.Text    = EditingCandidate.LastName;
                txtSuffix.Text      = EditingCandidate.Suffix;
                dtBirthdate.Checked = EditingCandidate.Birthdate.HasValue;
                if (dtBirthdate.Checked)
                {
                    dtBirthdate.Value = EditingCandidate.Birthdate.Value;
                }
                cmbSex.SelectedIndex      = (int)EditingCandidate.Sex - 1;
                cmbYearLevel.SelectedItem = EditingCandidate.YearLevel.ToString();
                txtSection.Text           = EditingCandidate.Section;
                txtAlias.Text             = EditingCandidate.Alias;

                pbImage.Image = Properties.Resources.default_candidate;
                if (!string.IsNullOrWhiteSpace(EditingCandidate.PictureFileName))
                {
                    var filePath = Path.Combine(App.ImageFolderPath, EditingCandidate.PictureFileName);
                    if (File.Exists(filePath))
                    {
                        using (var bmpTemp = new Bitmap(filePath))
                        {
                            pbImage.Image = new Bitmap(bmpTemp);
                        }
                    }
                }

                btnAdd.Text = "UPDATE";
            }

            Microsoft.Win32.SystemEvents.DisplaySettingsChanged += (s, ev) =>
            {
                G.PlaceWindowOnCenter(this);
            };

            Text = lblTitle.Text;
        }
예제 #6
0
        private void LoadPeople()
        {
            var peopleXml = _xmlRoot.SelectNodes("t:person", _nsm);
            var numToLoad = peopleXml.Count;

            if (peopleXml == null || numToLoad == 0)
            {
                throw new LoaderException("No people in the file");
            }

            _peopleModel = new PeopleModel(_election);
            var defaultReason = ElectionModel.GetDefaultIneligibleReason(_election);

            _people = new List <Person>();
            var rowsProcessed = 0;

            foreach (XmlElement personXml in peopleXml)
            {
                LoadPerson(personXml, _people, defaultReason);

                rowsProcessed++;
                if (rowsProcessed % 100 == 0)
                {
                    _hub.StatusUpdate("Processing {0:n0} people".FilledWith(rowsProcessed, numToLoad), true);
                }
            }

            Db.BulkInsert(_people);

            _hub.StatusUpdate("Loaded {0:n0} people.".FilledWith(rowsProcessed));
        }
예제 #7
0
        public int Add(ElectionModel model)
        {
            string query = "INSERT INTO public.election(e_name,e_village,e_dist,e_postcode) VALUES(@e_name,@e_village,@e_dist,@e_postcode)";
            int    i     = 0;

            try
            {
                con.Open();
                cmd = new NpgsqlCommand(query, con);
                cmd.Parameters.AddWithValue("@e_name", model.e_name);
                cmd.Parameters.AddWithValue("@e_village", model.e_village);
                cmd.Parameters.AddWithValue("@e_dist", model.e_dist);
                cmd.Parameters.AddWithValue("@e_postcode", model.e_postcode);
                i = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(i);
        }
예제 #8
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            if (Voter == null)
            {
                lblTitle.Content = "Add Voter";

                btnAdd.Content = "ADD";
            }
            else
            {
                lblTitle.Content = "Edit Voter";

                txtVoterID.Text          = Voter.Vin;
                txtLastName.Text         = Voter.LastName;
                txtFirstName.Text        = Voter.FirstName;
                txtMiddleName.Text       = Voter.MiddleName;
                cmbGradeLevel.Text       = Voter.YearLevel.ToString();
                txtStrandSection.Text    = Voter.Section;
                cmbSex.Text              = Voter.Sex.ToString();
                dpBirthdate.SelectedDate = Voter.Birthdate;

                btnAdd.Content = "UPDATE";
            }
        }
예제 #9
0
        private async void PartyForm_Load(object sender, EventArgs e)
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            if (Party == null)
            {
                lblTitle.Text     = "Create Party";
                btnAdd.Text       = "ADD";
                btnDelete.Visible = false;

                var random = new Random();
                _argb = (int)(0xFF000000 + (random.Next(0xFFFFFF) & 0x7F7F7F));

                pbColor.BackColor = Color.FromArgb(_argb);
            }
            else
            {
                lblTitle.Text = "Edit Party";
                btnAdd.Text   = "UPDATE";

                txtName.Text           = Party.Title;
                txtName.SelectionStart = txtName.TextLength;
                txtShortName.Text      = Party.ShortName;
                pbColor.BackColor      = Party.Color;

                _argb = Party.Argb;

                btnDelete.Visible = true;
            }

            Text = lblTitle.Text;
        }
예제 #10
0
        public List <ElectionModel> ReadData2()
        {
            var listData = new List <ElectionModel>();

            using (var reader = new StreamReader(FilePath))
            {
                var dataFromRead      = reader.ReadToEnd();
                var dataFromSplitLine = dataFromRead.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
                foreach (var item in dataFromSplitLine)
                {
                    var listDataFromFile = item.Split(',');
                    int.TryParse(listDataFromFile[5], out int score);
                    var data = new ElectionModel
                    {
                        Id        = Guid.NewGuid().ToString(),
                        Name      = listDataFromFile[2],
                        NameParty = listDataFromFile[4],
                        No        = listDataFromFile[3],
                        NameArea  = $"{listDataFromFile[0]}{listDataFromFile[1]}",
                        Score     = score
                    };
                    listData.Add(data);
                }
            }
            return(listData);
        }
        protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext)
        {
            var authorized = base.AuthorizeCore(httpContext) && (UserSession.IsGuestTeller || UserSession.IsKnownTeller);

            if (!authorized)
            {
                // The user is not authenticated
                return(false);
            }

            var electionModel = new ElectionModel();

            if (UserSession.IsGuestTeller)
            {
                if (!electionModel.GuestsAllowed())
                {
                    UserSession.ProcessLogout();
                    return(false);
                }
                return(true);
            }

            // only update visit every 5 minutes. Lasts for 1 hour, so could be only 45 minutes.
            var currentElection = UserSession.CurrentElection;
            var delayTime       = TimeSpan.FromMinutes(5);

            if (currentElection != null && currentElection.ListForPublic.AsBoolean())
            {
                LogTime("init");
                var db = UnityInstance.Resolve <IDbContextFactory>().GetNewDbContext;
                LogTime("resolve");

                db.Election.Attach(currentElection);
                LogTime("attach");

                currentElection.ListedForPublicAsOf = DateTime.Now;

                LogTime("listed");
                var electionCacher = new ElectionCacher(db);
                LogTime("cacher");

                electionCacher.UpdateItemAndSaveCache(currentElection);
                LogTime("update cache");

                if (currentElection.ListForPublic.AsBoolean() &&
                    (DateTime.Now - currentElection.ListedForPublicAsOf.GetValueOrDefault(DateTime.Now.AddMinutes(-60))).TotalMinutes > delayTime.TotalMinutes)
                {
                    db.SaveChanges();

                    LogTime("db save");
                }

                new PublicHub().TellPublicAboutVisibleElections();
                LogTime("notify");
            }

            return(true);
        }
예제 #12
0
        public async Task UpdateElectionAsync(ElectionModel model)
        {
            using (var context = new StudentElectionContext())
            {
                var election = await context.Elections.SingleOrDefaultAsync(c => c.Id == model.Id);

                _mapper.Map(model, election);

                await context.SaveChangesAsync();
            }
        }
예제 #13
0
        public async Task <int> AddElectionAsync(ElectionModel model)
        {
            using (var context = new StudentElectionContext())
            {
                var election = new Election();
                _mapper.Map(model, election);

                context.Elections.Add(election);

                return(await context.SaveChangesAsync());
            }
        }
        private async void PositionForm_Load(object sender, EventArgs e)
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            _window = (Tag as MaintenanceWindow);

            await LoadPositionsAsync();

            nudNumberOfWinners.Value    = Math.Min(2, nudNumberOfWinners.Maximum);
            nudNumberOfWinners.Value    = 1;
            cmbWhoCanVote.SelectedIndex = 0;
        }
예제 #15
0
        public async Task InsertElectionAsync(ElectionModel model)
        {
            var election = new Election();

            _mapper.Map(model, election);

            using (var context = new StudentElectionContext())
            {
                context.Elections.Add(election);

                await context.SaveChangesAsync();
            }
        }
        public async Task <BallotModel> GetBallotAsync(ElectionModel election, VoterModel voter)
        {
            var existingBallot = await _ballotRepository.GetBallotByVinAsync(election.Id, voter.Vin);

            if (existingBallot == null)
            {
                var enteredAt = DateTime.Now;
                existingBallot = await _ballotRepository.InsertBallotAsync(voter, enteredAt);

                existingBallot.Code = GetBallotCode(election.ServerTag, existingBallot);
                await _ballotRepository.SetBallotCodeAsync(existingBallot);
            }

            return(existingBallot);
        }
        public async Task UpdateElectionAsync(ElectionModel election)
        {
            await Task.CompletedTask;

            using (var tableAdapter = new ElectionTableAdapter())
            {
                tableAdapter.Update(
                    election.Title,
                    election.Description,
                    election.TookPlaceOn,
                    election.CandidatesFinalizedAt,
                    election.ClosedAt,
                    election.ServerTag,
                    election.Id
                    );
            }
        }
예제 #18
0
        private async Task SetCurrentElectionAsync()
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            if (_currentElection != null)
            {
                if (_currentElection.ClosedAt.HasValue)
                {
                    grdFinalizeCandidates.Visibility = Visibility.Collapsed;
                    grdVoting.Visibility             = Visibility.Collapsed;
                    grdVoteEnded.Visibility          = Visibility.Visible;
                }
                else
                {
                    if (_currentElection.CandidatesFinalizedAt.HasValue)
                    {
                        grdFinalizeCandidates.Visibility = Visibility.Collapsed;
                        grdVoting.Visibility             = Visibility.Visible;
                        grdVoteEnded.Visibility          = Visibility.Collapsed;
                    }
                    else
                    {
                        grdFinalizeCandidates.Visibility = Visibility.Visible;
                        grdVoting.Visibility             = Visibility.Collapsed;
                        grdVoteEnded.Visibility          = Visibility.Collapsed;
                    }
                }

                this.Title = $"{ _currentElection.Title } • { (string.IsNullOrWhiteSpace(_currentElection.ServerTag) ? "(No tag)" : _currentElection.ServerTag) }";
            }
            else
            {
                this.Title = "Student Election System";

                grdNoElection.Visibility = Visibility.Visible;
            }

            //var fileName = "D:/Videos/New Text Document.txt";
            //FileSecurity fSecurity = File.GetAccessControl(fileName);

            //fSecurity.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.ReadData, AccessControlType.Allow));

            //File.SetAccessControl(fileName, fSecurity);
            //DB.LoadData();
        }
        public async Task <ElectionModel> GetElectionByServerTagAsync(string tag)
        {
            await Task.CompletedTask;

            using (var tableAdapter = new ElectionTableAdapter())
            {
                var row = tableAdapter.GetElectionsByServerTag(tag).SingleOrDefault();
                if (row == null)
                {
                    return(null);
                }

                var model = new ElectionModel();
                _mapper.Map(row, model);

                return(model);
            }
        }
        public async Task <ElectionModel> GetCurrentElectionAsync()
        {
            await Task.CompletedTask;

            using (var tableAdapter = new ElectionTableAdapter())
            {
                var row = tableAdapter.GetCurrentElections().SingleOrDefault();
                if (row == null)
                {
                    return(null);
                }

                var model = new ElectionModel();
                _mapper.Map(row, model);

                return(model);
            }
        }
예제 #21
0
        public JsonResult SelectElection(Guid guid, Guid?oldComputerGuid)
        {
            var electionModel = new ElectionModel();

            if (electionModel.JoinIntoElection(guid, oldComputerGuid.AsGuid()))
            {
                return(new
                {
                    Locations = ContextItems.LocationModel.GetLocations_Physical().OrderBy(l => l.SortOrder).Select(l => new { l.Name, l.C_RowId }),
                    Selected = true,
                    ElectionName = UserSession.CurrentElectionName,
                    ElectionGuid = UserSession.CurrentElectionGuid,
                    CompGuid = UserSession.CurrentComputer.ComputerGuid,
                    // Pulse = new PulseModel(this).Pulse()
                }.AsJsonResult());
            }
            return(new { Selected = false }.AsJsonResult());
        }
예제 #22
0
        public async Task <ElectionModel> GetElectionByServerTagAsync(string tag)
        {
            using (var context = new StudentElectionContext())
            {
                var election = await context.Elections
                               .SingleOrDefaultAsync(e => e.ServerTag.ToLower() == tag.ToLower());

                if (election == null)
                {
                    return(null);
                }

                var model = new ElectionModel();
                _mapper.Map(election, model);

                return(model);
            }
        }
예제 #23
0
        public async Task <ElectionModel> GetCurrentElectionAsync()
        {
            using (var context = new StudentElectionContext())
            {
                var election = await context.Elections
                               .OrderByDescending(e => e.TookPlaceOn)
                               .ThenByDescending(e => e.Id).FirstOrDefaultAsync();

                if (election == null)
                {
                    return(null);
                }

                var model = new ElectionModel();
                _mapper.Map(election, model);

                return(model);
            }
        }
예제 #24
0
        private async void CandidateViewerForm_Load(object sender, EventArgs e)
        {
            _window = (Tag as MaintenanceWindow);

            _currentElection = await _electionService.GetCurrentElectionAsync();

            btnEdit.Visible   = !_currentElection.CandidatesFinalizedAt.HasValue;
            btnDelete.Visible = !_currentElection.CandidatesFinalizedAt.HasValue;

            _candidateParty = (await _candidateService.GetCandidateDetailsListByPartyAsync(CurrentCandidate.PartyId)).ToList();

            _index = _candidateParty.Select(x => x.Id).ToList().IndexOf(CurrentCandidate.Id);

            btnNext.Enabled = _index != _candidateParty.Count - 1;
            btnPrev.Enabled = _index != 0;

            lblCandidatePage.Text = (_index + 1) + " of " + (_candidateParty.Count);

            SetCandidate();
        }
예제 #25
0
        public IHttpActionResult UpdateRecord(JObject model)
        {
            ElectionModel mod = new ElectionModel();
            var           s   = JsonConvert.DeserializeObject <List <ElectionModel> >(model["models"].ToString());

            mod.e_id       = s[0].e_id;
            mod.e_name     = s[0].e_name;
            mod.e_village  = s[0].e_village;
            mod.e_dist     = s[0].e_dist;
            mod.e_postcode = s[0].e_postcode;
            int i = repo.update(mod);

            if (i >= 1)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #26
0
        public Election()
        {
            Convenor      = "[Convener]"; // correct spelling is Convener. DB field name is wrong.
            ElectionGuid  = Guid.NewGuid();
            Name          = "[New Election]";
            ElectionType  = "LSA";
            ElectionMode  = ElectionModeEnum.Normal;
            TallyStatus   = ElectionTallyStatusEnum.NotStarted;
            NumberToElect = 9;
            NumberExtra   = 0;
            VotingMethods = "PDM";

            var rules = new ElectionModel().GetRules(ElectionType, ElectionMode);

            // No longer used as rules. Each person has own status.
            // CanVote = rules.CanVote;
            // CanReceive = rules.CanReceive;

            NumberToElect = rules.Num;
            NumberExtra   = rules.Extra;
        }
        public async Task InsertElectionAsync(ElectionModel model)
        {
            await Task.CompletedTask;

            using (var dataSet = new StudentElectionDataSet())
            {
                using (var manager = new TableAdapterManager())
                {
                    manager.ElectionTableAdapter = new ElectionTableAdapter();

                    var newRow = dataSet.Election.NewElectionRow();
                    _mapper.Map(model, newRow);
                    newRow.ID = -1;
                    newRow.SetCandidatesFinalizedAtNull();
                    newRow.SetClosedAtNull();

                    dataSet.Election.AddElectionRow(newRow);

                    manager.UpdateAll(dataSet);
                }
            }
        }
예제 #28
0
        public List <ElectionModel> ReadDataFromCSVFile()
        {
            var electionDataList = new List <ElectionModel>();

            using (var reader = new StreamReader(csvFile))
            {
                while (!reader.EndOfStream)
                {
                    var dataFromFile = reader.ReadLine();
                    var splitData    = dataFromFile.Split(",");
                    var electionData = new ElectionModel()
                    {
                        Id        = Guid.NewGuid().ToString(),
                        Name      = splitData[2],
                        NameParty = splitData[4],
                        No        = splitData[3],
                        NameArea  = $"{splitData[0]}{splitData[1]}",
                        Score     = Int32.Parse(splitData[5])
                    };
                    electionDataList.Add(electionData);
                }
            }
            return(electionDataList);
        }
예제 #29
0
        private async Task LoadElectionAsync()
        {
            _currentElection = await _electionService.GetCurrentElectionAsync();

            _canOpenNewElection = _currentElection == null || _currentElection.ClosedAt.HasValue;

            btnEdit.Visible = _currentElection.CandidatesFinalizedAt == null;

            if (_canOpenNewElection)
            {
                btnOpenOrCloseElection.Text = "OPEN NEW ELECTION";
            }
            else
            {
                btnOpenOrCloseElection.Text = "CLOSE ELECTION";
            }

            if (_currentElection != null)
            {
                lblCurrentElectionTitle.Text = _currentElection.Title;
                if (string.IsNullOrEmpty(_currentElection.Description))
                {
                    lblDescription.Text = "(no description)";
                    lblDescription.Font = new Font(lblDescription.Font, FontStyle.Italic);
                }
                else
                {
                    lblDescription.Text = _currentElection.Description;
                    lblDescription.Font = new Font(lblDescription.Font, FontStyle.Regular);
                }

                if (_currentElection.TookPlaceOn > DateTime.Today)
                {
                    lblTookPlaceOnLabel.Text = $"Will be conducted on { _currentElection.TookPlaceOn.ToString("MMMM d, yyyy") }";
                }
                else if (_currentElection.TookPlaceOn < DateTime.Today || _currentElection.ClosedAt.HasValue)
                {
                    lblTookPlaceOnLabel.Text = $"Took place on { _currentElection.TookPlaceOn.ToString("MMMM d, yyyy") }";
                }
                else
                {
                    lblTookPlaceOnLabel.Text = $"Conducting today, { _currentElection.TookPlaceOn.ToString("MMMM d, yyyy") }";
                }
                lblTookPlaceOn.Text = _currentElection.TookPlaceOn.Date.Humanize(dateToCompareAgainst: DateTime.Today);

                if (_currentElection.CandidatesFinalizedAt == null)
                {
                    lblCandidatesFinalizedAt.Text = "(not finalized yet)";
                    lblCandidatesFinalizedAt.Font = new Font(lblCandidatesFinalizedAt.Font, FontStyle.Regular);
                }
                else
                {
                    lblCandidatesFinalizedAt.Text = _currentElection.CandidatesFinalizedAt.Value.ToString("yyyy-MM-dd hh:mm:ss tt");
                    lblCandidatesFinalizedAt.Font = new Font(lblCandidatesFinalizedAt.Font, FontStyle.Bold);
                }

                if (_currentElection.ClosedAt == null)
                {
                    lblClosedAt.Text = "(not closed yet)";
                    lblClosedAt.Font = new Font(lblCandidatesFinalizedAt.Font, FontStyle.Regular);
                }
                else
                {
                    lblClosedAt.Text = _currentElection.ClosedAt.Value.ToString("yyyy-MM-dd hh:mm:ss tt");
                    lblClosedAt.Font = new Font(lblCandidatesFinalizedAt.Font, FontStyle.Bold);
                }
            }
        }
 public async Task <BallotModel> GetBallotByVinAsync(ElectionModel election, VoterModel voter)
 {
     return(await _ballotRepository.GetBallotByVinAsync(election.Id, voter.Vin));
 }