/// <summary> /// Retrieves a collection of Post Election Draft Audit Response Inadequate Response events for a specific candidate and election cycle. /// </summary> /// <param name="candidateID">The ID of the candidate whose DAR Inadequate Response events are to be retrieved.</param> /// <param name="electionCycle">The election cycle in which to search.</param> /// <param name="retrievalType">The type of inadequate event criteria to use for retrieval.</param> /// <returns>A collection of Post Election Draft Audit Response Inadequate Response events matching the specified criteria.</returns> public List <DarInadequateEvent> GetDarInadequateEvents(string candidateID, string electionCycle, InadequateEventRetrieval retrievalType) { using (DataClient client = new DataClient()) { return(client.GetDarInadequateEvents(candidateID, electionCycle, retrievalType)); } }
/// <summary> /// Retrieves a collection of Post Election Draft Audit Response Inadequate Response events for a specific candidate and election cycle. /// </summary> /// <param name="candidateID">The ID of the candidate whose DAR Inadequate Response events are to be retrieved.</param> /// <param name="electionCycle">The election cycle in which to search.</param> /// <param name="retrievalType">The type of inadequate event criteria to use for retrieval.</param> /// <returns>A collection of Post Election Draft Audit Response Inadequate Response events matching the specified criteria.</returns> public List <DarInadequateEvent> GetDarInadequateEvents(string candidateID, string electionCycle, InadequateEventRetrieval retrievalType) { // interpret retrieval type bool?additionals; switch (retrievalType) { case InadequateEventRetrieval.InitialEvent: additionals = false; break; case InadequateEventRetrieval.AdditionalEvents: additionals = true; break; default: additionals = null; break; } // determine minimum start date DateTime?minStartDate = GetTollingStartDate(electionCycle); // retrieve and parse data using (PostElectionTds ds = new PostElectionTds()) { using (InadequateEventsTableAdapter ta = new InadequateEventsTableAdapter()) { ta.Fill(ds.InadequateEvents, candidateID, electionCycle, true, additionals); } List <DarInadequateEvent> events = new List <DarInadequateEvent>(); foreach (PostElectionTds.InadequateEventsRow row in ds.InadequateEvents) { TollingLetter letter = GetTollingLetter(row.SourceCode.Trim(), row.EventCode.Trim(), row.TypeCode.Trim()) ?? new TollingLetter(byte.MinValue) { SourceCode = new TollingCode(TollingCodeType.SourceCode, byte.MinValue) { Code = row.SourceCode.Trim() }, EventCode = new TollingCode(TollingCodeType.EventCode, byte.MinValue) { Code = row.EventCode.Trim() }, TypeCode = new TollingCode(TollingCodeType.TypeCode, byte.MinValue) { Code = row.TypeCode.Trim() }, Description = row.Description, Title = row.Description }; // first fetch end reason to determine end date inclusion in tolling days TollingEndReason reason = CPConvert.ToTollingEndReason(row.EndReasonCode.Trim()); DarInadequateEvent inadequate = new DarInadequateEvent(row.SentDate, row.IsAdditionalFlagNull() ? false : row.AdditionalFlag) { ReceiptDate = row.IsReceiptDateNull() ? null : (DateTime?)row.ReceiptDate, SecondSentDate = row.IsSecondSentDateNull() ? null : (DateTime?)row.SecondSentDate, SecondReceiptDate = row.IsSecondReceiptDateNull() ? null : (DateTime?)row.SecondReceiptDate, ResponseSubmittedDate = row.IsResponseSubmittedDateNull() ? null : (DateTime?)row.ResponseSubmittedDate, // tolling event properties Description = letter.Description, Title = letter.Title, TollingEventNumber = row.EventNumber, TollingLetter = letter, TollingStartDate = minStartDate.HasValue && row.StartDate < minStartDate ? minStartDate.Value : row.StartDate, TollingEndDate = row.IsEndDateNull() ? null : (DateTime?)row.EndDate, TollingEndReason = reason }; inadequate.ResponseDeadline = new DarInadequateDeadline(row.DueDate, inadequate) { ResponseReceivedDate = row.IsResponseReceivedDateNull() ? null : (DateTime?)row.ResponseReceivedDate, SecondDueDate = row.IsSecondDueDateNull() ? null : (DateTime?)row.SecondDueDate }; events.Add(inadequate); } return(events); } }