// Load all elections from Backend and show them in Form

        /// <summary>
        /// Load all elections. Create <c>ElectionControl</c> objects for them and add them to the List of frontend elections
        /// </summary>
        /// <returns>A Task</returns>
        public async Task LoadElections()
        {
            await WaitForElections();

            foreach (TmpElectionObject election in this.elections)
            {
                ElectionControl electionControl = new ElectionControl();
                electionControl.SetName(election.Name);
                electionControl.SetId((int)election.Id);
                electionControl.SetTimestamp("Start: " + UnixTimeStampToDateTime((double)election.StartTimestamp).ToString() + "   "
                                             + "End: " + UnixTimeStampToDateTime((double)election.EndTimestamp).ToString());

                frontendElections.Add(electionControl);
            }
        }
        /// <summary>
        /// Validates the picked election and sets the selected election in the backend.
        /// Shows error messages to user if the input is wrong
        /// </summary>
        /// <returns>True if the method was successful
        /// False if there was and error</returns>
        public bool ValidatePick()
        {
            ElectionControl pickedElectionControl = null;
            int             checkedItems          = 0;

            foreach (ElectionControl ec in frontendElections)
            {
                if (ec.GetChecked())
                {
                    checkedItems++;
                    pickedElectionControl = ec;
                    pickedElection        = elections.Find(x => (x.Id == ec.GetId()));
                }
            }

            if (checkedItems < 1)
            {
                MessageBox.Show("You have to pick an election");
                return(false);
            }

            if (checkedItems > 1)
            {
                MessageBox.Show("You can only pick one election");
                return(false);
            }

            // everything is oke. Set picked election ID in backend and return true
            if (pickedElectionControl != null)
            {
                Backend.SetCurrentElection(pickedElectionControl.GetId());
                return(true);
            }
            else
            {
                return(false);
            }
        }