/// <summary> /// Retrieves a collection of Post Election Initial Documentation Inadequate Response events for a specific candidate and election cycle. /// </summary> /// <param name="candidateID">The ID of the candidate whose IDR Inadequate Response events is 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 Initial Documentation Inadequate Response events matching the specified criteria.</returns> public List <IdrInadequateEvent> GetIdrInadequateEvents(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, false, additionals); } List <IdrInadequateEvent> events = new List <IdrInadequateEvent>(); 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()); IdrInadequateEvent inadequate = new IdrInadequateEvent(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 IdrInadequateDeadline(row.DueDate, inadequate) { ResponseReceivedDate = row.IsResponseReceivedDateNull() ? null : (DateTime?)row.ResponseReceivedDate, SecondDueDate = row.IsSecondDueDateNull() ? null : (DateTime?)row.SecondDueDate }; events.Add(inadequate); } return(events); } }
/// <summary> /// Retrieves the Post Election Initial Documentation Request Inadequate Response event for a specific candidate and election cycle. /// </summary> /// <param name="candidateID">The ID of the candidate whose IDR Inadequate Response event is to be retrieved.</param> /// <param name="electionCycle">The election cycle in which to search.</param> /// <param name="published">Whether or not to retrieve published data.</param> /// <returns>The Post Election Initial Documentation Request Inadequate Response event for the candidate and election cycle specified if found; otherwise, null.</returns> public IdrInadequateEvent GetIdrInadequateEvent(string candidateID, string electionCycle, bool published) { IdrInadequateEvent inadequate = null; using (PostElectionTds ds = new PostElectionTds()) { if (published) { DateTime?minStartDate = GetTollingStartDate(electionCycle); using (InadequateEventsTableAdapter ta = new InadequateEventsTableAdapter()) { ta.Fill(ds.InadequateEvents, candidateID, electionCycle, false, false); } 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()); inadequate = new IdrInadequateEvent(row.SentDate) { 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 IdrInadequateDeadline(row.DueDate, inadequate) { ResponseReceivedDate = row.IsResponseReceivedDateNull() ? null : (DateTime?)row.ResponseReceivedDate, SecondDueDate = row.IsSecondDueDateNull() ? null : (DateTime?)row.SecondDueDate }; break; } } else { using (InadequateEventsDirectTableAdapter ta = new InadequateEventsDirectTableAdapter()) { ta.Fill(ds.InadequateEventsDirect, candidateID, electionCycle, false, false); } foreach (PostElectionTds.InadequateEventsDirectRow row in ds.InadequateEventsDirect) { inadequate = new IdrInadequateEvent(row.SentDate) { 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 }; inadequate.ResponseDeadline = new IdrInadequateDeadline(row.DueDate, inadequate) { ResponseReceivedDate = row.IsResponseReceivedDateNull() ? null : (DateTime?)row.ResponseReceivedDate, SecondDueDate = row.IsSecondDueDateNull() ? null : (DateTime?)row.SecondDueDate }; break; } } } return(inadequate); }