Пример #1
0
        /// <summary>
        ///   Combine the automatic count with any values saved into a "Manual" result summary record
        /// </summary>
        public void CombineCalcAndManualSummaries()
        {
            var manualOverride = ResultSummaries.FirstOrDefault(rs => rs.ResultType == ResultType.Manual)
                                 ?? new ResultSummary();

            // allow override of some

            ResultSummaryFinal.NumEligibleToVote = manualOverride.NumEligibleToVote.HasValue
              ? manualOverride.NumEligibleToVote.Value
              : ResultSummaryCalc.NumEligibleToVote.GetValueOrDefault();

            ResultSummaryFinal.InPersonBallots = manualOverride.InPersonBallots.HasValue
              ? manualOverride.InPersonBallots.Value
              : ResultSummaryCalc.InPersonBallots.GetValueOrDefault();

            ResultSummaryFinal.DroppedOffBallots = manualOverride.DroppedOffBallots.HasValue
              ? manualOverride.DroppedOffBallots.Value
              : ResultSummaryCalc.DroppedOffBallots.GetValueOrDefault();

            ResultSummaryFinal.MailedInBallots = manualOverride.MailedInBallots.HasValue
              ? manualOverride.MailedInBallots.Value
              : ResultSummaryCalc.MailedInBallots.GetValueOrDefault();

            ResultSummaryFinal.CalledInBallots = manualOverride.CalledInBallots.HasValue
              ? manualOverride.CalledInBallots.Value
              : ResultSummaryCalc.CalledInBallots.GetValueOrDefault();


            // no overrides

            // Received --> now is used for Valid ballots
            ResultSummaryFinal.BallotsReceived = ResultSummaryCalc.BallotsReceived.GetValueOrDefault();

            ResultSummaryFinal.NumVoters = manualOverride.NumVoters.HasValue
              ? manualOverride.NumVoters.Value
              : ResultSummaryCalc.NumVoters.GetValueOrDefault();

            ResultSummaryFinal.SpoiledManualBallots = manualOverride.SpoiledManualBallots;

            ResultSummaryFinal.BallotsNeedingReview = ResultSummaryCalc.BallotsNeedingReview;

            // add manual to calculated
            ResultSummaryFinal.SpoiledBallots =
                manualOverride.SpoiledManualBallots.GetValueOrDefault()
                + ResultSummaryCalc.SpoiledBallots.GetValueOrDefault();

            ResultSummaryFinal.SpoiledVotes = ResultSummaryCalc.SpoiledVotes;

            //ResultSummaryFinal.TotalVotes = manualInput.TotalVotes.HasValue
            //                                    ? manualInput.TotalVotes.Value
            //                                    : ResultSummaryCalc.TotalVotes.GetValueOrDefault();
        }
Пример #2
0
        /// <summary>
        ///   Load the Calc and Final summaries
        /// </summary>
        public void PrepareResultSummaries()
        {
            if (ResultSummaryCalc != null && ResultSummaryFinal != null)
            {
                return;
            }

            // check each on on its own
            if (ResultSummaryCalc == null)
            {
                ResultSummaryCalc = ResultSummaries.FirstOrDefault(rs => rs.ResultType == ResultType.Calculated);
                if (ResultSummaryCalc == null)
                {
                    ResultSummaryCalc = new ResultSummary
                    {
                        ElectionGuid = TargetElection.ElectionGuid,
                        ResultType   = ResultType.Calculated
                    };

                    Savers.ResultSummarySaver(DbAction.Add, ResultSummaryCalc);
                    ResultSummaries.Add(ResultSummaryCalc);
                }
            }

            if (ResultSummaryFinal == null)
            {
                ResultSummaryFinal = ResultSummaries.FirstOrDefault(rs => rs.ResultType == ResultType.Final);
                if (ResultSummaryFinal == null)
                {
                    ResultSummaryFinal = new ResultSummary
                    {
                        ElectionGuid = TargetElection.ElectionGuid,
                        ResultType   = ResultType.Final
                    };
                    Savers.ResultSummarySaver(DbAction.Add, ResultSummaryFinal);
                    ResultSummaries.Add(ResultSummaryFinal);
                }
            }
        }
Пример #3
0
 public void AddResultSummaryToDb(ResultSummary item)
 {
     ResultSummaries.Add(item);
 }
Пример #4
0
 public ResultSummary AddResultSummary(ResultSummary arg)
 {
     arg.C_RowId = ++_rowCounter;
     ResultSummaries.Add(arg);
     return(arg);
 }