Пример #1
0
            protected override bool Update(object newValue)
            {
                var changed = false;
                //Parse the value from the UI tree
                var valueStr = newValue as string;

                if (valueStr == null)
                {
                    return(false);
                }
                var offices = valueStr.Split(new[] { '|' },
                                             StringSplitOptions.RemoveEmptyEntries)
                              .Select(officeStr =>
                {
                    var officeSplit = officeStr.Split(':');
                    return
                    (new
                    {
                        OfficeKey = officeSplit[0],
                        Incumbents = officeSplit[1].Split(',')
                    });
                })
                              .ToArray();

                foreach (var office in offices)
                {
                    foreach (var incumbent in office.Incumbents)
                    {
                        var table =
                            ElectionsIncumbentsRemoved.GetDataByElectionKeyOfficeKeyPoliticianKey
                                (Page.GetElectionKey(), office.OfficeKey, incumbent);
                        if (table.Count == 1)
                        {
                            var row = table[0];
                            changed = true;
                            if (!OfficesOfficials.OfficeKeyPoliticianKeyExists(row.OfficeKey, row.PoliticianKey))
                            {
                                OfficesOfficials.Insert(row.OfficeKey, row.PoliticianKey,
                                                        row.RunningMateKey, row.StateCode, row.CountyCode, row.LocalCode,
                                                        row.DistrictCode,
                                                        //row.LDSVersion, row.LDSUpdateDate,
                                                        row.DataLastUpdated, row.UserSecurity, row.UserName);
                            }
                            ElectionsIncumbentsRemoved.DeleteByElectionKeyOfficeKeyPoliticianKey
                                (Page.GetElectionKey(), office.OfficeKey, incumbent);
                        }
                    }
                }

                //LoadControl();
                return(changed);
            }