public static CandidateSos FillCandidate(List <CellData> cellData, string officeName, string year)
        {
            var candidate = new CandidateSos()
            {
                OfficeName = officeName,
                Year       = year
            };


            foreach (var data in cellData)
            {
                var cellTextLen = data.CellText.Length;

                // get labeled text first

                if (data.CellText.Length < 5)
                {
                    // "N/A" or other junk
                    continue;
                }

                switch (data.CellText.Substring(0, 5))
                {
                case "E-mai":
                    candidate.Email = "Blocked";
                    break;

                case "INCUM":
                    if (cellTextLen > 11)
                    {
                        candidate.Incumbent = data.CellText.Remove(0, 11);
                    }
                    break;

                case "OCCUP":
                    if (cellTextLen > 12)
                    {
                        candidate.Occupation = data.CellText.Remove(0, 12);
                    }
                    break;

                case "QUALI":
                    if (cellTextLen > 16)
                    {
                        candidate.QualifiedDate = data.CellText.Remove(0, 16);
                    }
                    break;

                case "PARTY":
                    if (cellTextLen > 7)
                    {
                        candidate.Party = data.CellText.Remove(0, 7);
                    }
                    break;

                case "PHONE":
                    if (cellTextLen > 14)
                    {
                        candidate.PhoneNumber = data.CellText.Remove(0, 14);
                    }
                    break;

                case "WEBSI":
                    if (cellTextLen > 9)
                    {
                        candidate.Website = data.CellText.Remove(0, 9);
                    }

                    break;

                default:

                    switch (data.RowNum)
                    {
                    case 1:
                        candidate.CandidateName = data.CellText.Trim();
                        break;

                    case 2:
                        candidate.Address = data.CellText.Trim();
                        break;

                    case 3:
                        candidate.CityStZip = data.CellText.Trim();
                        break;

                    default:

                        break;          // Inner default
                    }                   // End Inner switch
                    break;              // Outer default
                }                       // End Outer switch
            }

            return(candidate);
        }
Beispiel #2
0
        public static CandidateSos FillCandidate(List <CellData> cellData, string officeName)
        {
            var candidate = new CandidateSos()
            {
                OfficeName = officeName
            };


            foreach (var data in cellData)
            {
                var cellTextLen = data.CellText.Length;

                switch (data.CellText.Substring(0, 5))
                {
                case "E-mai":
                    candidate.Email = "Unavailable";
                    break;

                case "INCUM":
                    if (cellTextLen > 11)
                    {
                        candidate.Incumbent = data.CellText.Remove(0, 11);
                    }
                    break;

                case "OCCUP":
                    if (cellTextLen > 12)
                    {
                        candidate.Occupation = data.CellText.Remove(0, 12);
                    }
                    break;

                case "QUALI":
                    if (cellTextLen > 16)
                    {
                        candidate.QualifiedDate = data.CellText.Remove(0, 16);
                    }
                    break;

                case "PARTY":
                    if (cellTextLen > 7)
                    {
                        candidate.Party = data.CellText.Remove(0, 7);
                    }
                    break;

                case "PHONE":
                    if (cellTextLen > 14)
                    {
                        data.CellText = data.CellText.Remove(0, 14);
                    }
                    break;

                case "WEBSI":
                    if (cellTextLen > 9)
                    {
                        candidate.Website = data.CellText.Remove(0, 9);
                    }

                    break;

                default:

                    // Must be Name Address, CityStZip
                    switch (data.RowNum)
                    {
                    case 1:
                        candidate.CandidateName = data.CellText;
                        break;

                    case 2:
                        candidate.Address = data.CellText;
                        break;

                    case 3:
                        candidate.CityStZip = data.CellText;
                        break;

                    default:

                        break;
                    }

                    break;
                }
            }



            return(candidate);
        }