Example #1
0
        public async Task <List <Models.Database.VoteCandidate> > GetCandidates()
        {
            var candidateList = new List <Models.Database.VoteCandidate>();

            using (var context = new toafcContext())
            {
                var temp = (from tempCandidate in context.VoteCandidates
                            join tempVotePeriod in context.VotePeriods on tempCandidate.VotePeriod equals tempVotePeriod.Id into votePeriodJoin
                            from votePeriodJoinVal in votePeriodJoin.DefaultIfEmpty()
                            select new Models.Database.VoteCandidate()
                {
                    Firstname = tempCandidate.Firstname,
                    IsDeleted = tempCandidate.IsDeleted,
                    Createdbyuser = tempCandidate.Createdbyuser,
                    Createdon = tempCandidate.Createdon,
                    Id = tempCandidate.Id,
                    Lastname = tempCandidate.Lastname,
                    Modifiedbyuser = tempCandidate.Modifiedbyuser,
                    Modifiedon = tempCandidate.Modifiedon,
                    VotePeriod = votePeriodJoinVal.Id
                }).ToList();
                candidateList = temp;
            }
            return(candidateList);
        }
Example #2
0
 public async Task <Boolean> IsVotingEnabled()
 {
     using (var context = new toafcContext())
     {
         return(context.VotingEnableds.FirstOrDefault().Status);
     }
 }
Example #3
0
        public async Task <List <Models.Database.VoteRegistration> > GetRegistredVoters()
        {
            var voterList = new List <Models.Database.VoteRegistration>();

            using (var context = new toafcContext())
            {
                var temp = (from tempVoterRegistration in context.VoteRegistrations
                            join tempVotePeriod in context.VotePeriods on tempVoterRegistration.VotePeriod equals tempVotePeriod.Id into votePeriodJoin
                            from votePeriodJoinVal in votePeriodJoin.DefaultIfEmpty()
                            select new Models.Database.VoteRegistration()
                {
                    Firstname = tempVoterRegistration.Firstname,
                    Createdbyuser = tempVoterRegistration.Createdbyuser,
                    Createdon = tempVoterRegistration.Createdon,
                    Id = tempVoterRegistration.Id,
                    IsElgible = tempVoterRegistration.IsElgible,
                    Lastname = tempVoterRegistration.Lastname,
                    Modifiedbyuser = tempVoterRegistration.Modifiedbyuser,
                    Modifiedon = tempVoterRegistration.Modifiedon,
                    VotePeriod = votePeriodJoinVal.Id
                }).ToList();
                voterList = temp;
            }
            return(voterList);
        }
Example #4
0
 public async Task <List <Models.Database.VotePeriod> > GetVotePeriods()
 {
     using (var context = new toafcContext())
     {
         return(context.VotePeriods.ToList());
     }
 }
Example #5
0
 public async Task <Models.Database.VoteRegistration> UpdateRegistration(Models.Database.VoteRegistration voteRegistration)
 {
     using (var context = new toafcContext())
     {
         context.VoteRegistrations.Update(voteRegistration);
         await context.SaveChangesAsync();
     }
     return(voteRegistration);
 }
Example #6
0
 public async Task <Models.Database.VoteCandidate> UpdateCandidate(Models.Database.VoteCandidate voteCandidate)
 {
     using (var context = new toafcContext())
     {
         context.VoteCandidates.Update(voteCandidate);
         await context.SaveChangesAsync();
     }
     return(voteCandidate);
 }
Example #7
0
 public async Task <Models.Database.VotePeriod> SetVotePeriod(Models.Database.VotePeriod votePeriod)
 {
     using (var context = new toafcContext())
     {
         context.VotePeriods.Add(votePeriod);
         await context.SaveChangesAsync();
     }
     return(votePeriod);
 }
Example #8
0
 public async Task <Models.Database.VoterTally> InsertTally(Models.Database.VoterTally voterTally)
 {
     voterTally.IsDeleted = false;
     using (var context = new toafcContext())
     {
         context.VoterTallies.Add(voterTally);
         await context.SaveChangesAsync();
     }
     return(voterTally);
 }
Example #9
0
        public async Task <List <Models.Database.VoterTally> > GetVoterTally()
        {
            var voterTalley = new List <Models.Database.VoterTally>();

            using (var context = new toafcContext())
            {
                var temp = context.VoterTallies.Where(x => x.IsDeleted == false).ToList();
                voterTalley = temp;
            }
            return(voterTalley);
        }
Example #10
0
        public async Task <Boolean> Update(Boolean input)
        {
            using (var context = new toafcContext())
            {
                context.VotingEnableds.Add(new Models.Database.VotingEnabled()
                {
                    Status = input
                });
                await context.SaveChangesAsync();

                return(input);
            }
        }