Пример #1
0
        public async Task <int> CountVotedVotersAsync(int electionId)
        {
            await Task.CompletedTask;

            using (var tableAdapter = new VoterTableAdapter())
            {
                var result = tableAdapter.CountVotedVotersQuery(electionId);
                return(Convert.ToInt32(result ?? 0));
            }
        }
Пример #2
0
        public async Task DeleteVoterAsync(VoterModel voter)
        {
            await Task.CompletedTask;

            using (var tableAdapter = new VoterTableAdapter())
            {
                tableAdapter.Delete(
                    voter.Id
                    );
            }
        }
Пример #3
0
        public async Task <IEnumerable <VoterModel> > GetVoterDetailsListAsync(int electionId)
        {
            await Task.CompletedTask;

            using (var tableAdapter = new VoterTableAdapter())
            {
                var users = tableAdapter.GetVoterDetailsList(electionId)
                            .AsQueryable <DataRow>();

                return(_mapper.ProjectTo <VoterModel>(users)
                       .AsEnumerable());
            }
        }
Пример #4
0
        public async Task <VoterModel> GetVoterAsync(int voterId)
        {
            await Task.CompletedTask;

            using (var tableAdapter = new VoterTableAdapter())
            {
                var row = tableAdapter.GetVotersById(voterId).SingleOrDefault();
                if (row == null)
                {
                    return(null);
                }

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

                return(model);
            }
        }
Пример #5
0
        public async Task <VoterModel> GetVoterByVinAsync(int electionId, string vin)
        {
            await Task.CompletedTask;

            using (var tableAdapter = new VoterTableAdapter())
            {
                var row = tableAdapter.GetVotersByVin(vin, electionId).SingleOrDefault();
                if (row == null)
                {
                    return(null);
                }

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

                return(model);
            }
        }
Пример #6
0
        public async Task InsertVoterAsync(VoterModel voter)
        {
            await Task.CompletedTask;

            using (var tableAdapter = new VoterTableAdapter())
            {
                tableAdapter.Insert(
                    voter.FirstName,
                    voter.MiddleName,
                    voter.LastName,
                    voter.Suffix,
                    (int)voter.Sex,
                    voter.Birthdate,
                    voter.Vin,
                    voter.YearLevel,
                    voter.Section,
                    voter.ElectionId
                    );
            }
        }
Пример #7
0
        public static void LoadData()
        {
            var userAdapter = new UserTableAdapter();
            var userData    = userAdapter.GetData();

            foreach (var row in userData)
            {
                var newRow = DataSet.User.NewUserRow();

                newRow.ID         = row.ID;
                newRow.LastName   = row.LastName;
                newRow.FirstName  = row.FirstName;
                newRow.MiddleName = row.IsMiddleNameNull() ? "" : row.MiddleName;
                newRow.Type       = row.Type;

                DataSet.User.AddUserRow(newRow);
            }

            var machineAdapter = new MachineTableAdapter();
            var machineData    = machineAdapter.GetData();

            foreach (var row in machineData)
            {
                var newRow = DataSet.Machine.NewMachineRow();

                newRow.ID              = row.ID;
                newRow.IsFinalized     = row.IsFinalized;
                newRow.IsResultsViewed = row.IsResultsViewed;
                newRow.Name            = row.IsNameNull() ? "" : row.Name;

                DataSet.Machine.AddMachineRow(newRow);
            }

            var staffAdapter = new StaffTableAdapter();
            var staffData    = staffAdapter.GetData();

            foreach (var row in staffData)
            {
                var newRow = DataSet.Staff.NewStaffRow();

                newRow.UserRow  = DataSet.User.FindByID(row.UserID);
                newRow.Username = row.Username;
                newRow.Password = row.Password;

                DataSet.Staff.AddStaffRow(newRow);
            }

            var voterAdapter = new VoterTableAdapter();
            var voterData    = voterAdapter.GetData();

            foreach (var row in voterData)
            {
                var newRow = DataSet.Voter.NewVoterRow();

                newRow.ID            = row.ID;
                newRow.GradeLevel    = row.GradeLevel;
                newRow.StrandSection = row.StrandSection;
                newRow.IsMale        = row.IsMale;
                newRow.Birthday      = row.Birthday;
                newRow.VoterID       = row.VoterID;
                newRow.IsForeign     = row.IsForeign;
                newRow.MachineRow    = DataSet.Machine.FindByID(row.MachineID);

                DataSet.Voter.AddVoterRow(newRow);
            }
        }