public IActionResult Index()
        {
            var model = new CentralGovernmentVm
            {
                CandidatesList = _candidatesService.GetAllCandidates(),

                ElectionStages = _stateService.GetAllStates()
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public IActionResult Index()
        {
            bool isAuthenticated = User.Identity.IsAuthenticated;
            bool role            = User.IsInRole("Administrator");

            if (!isAuthenticated)
            {
                return(RedirectToAction("Index", "Home"));
                //redirect to login page
            }

            var RegistrationPhase = new SessionRegistrationPhase
            {
                RegistrationSessionBegan = _stateService.ResolveRegistrationPhaseHasBegan(),

                HasAgreedToTermsAndConditions = _userService.HasUserAgreedToTermsAndConditions(),
                IsRegisteredForElection       = _userService.IsUserRegisteredForElection(),


                RegistrationHasEnded = _stateService.ResolveRegistrationPhaseHasEnded(),
            };


            var VotingPhase = new SessionVotingPhase
            {
                VotingHasBegan = _stateService.ResolveVotingPhaseHasBegan(),


                UserHasVotedForCandidate = _userService.HasUserVotedForCandidate(),

                VotingSessionHasEnded = _stateService.ResolveVotingPhaseHasEnded(),
            };


            var CandidatesList = _candidatesService.GetAllCandidates();


            return(View(new SessionVM
            {
                CandidatesList = CandidatesList,
                VotingPhase = VotingPhase,
                RegistrationPhase = RegistrationPhase
            }));
        }
Ejemplo n.º 3
0
        public IActionResult GetAll(int pageNumber, int pageSize)
        {
            var result = _candidatesService.GetAllCandidates(pageNumber, pageSize);

            return(Ok(result));
        }