Ejemplo n.º 1
0
 private static void DeleteAllPoliticianReferences(string politicianKey)
 {
     Answers2.DeleteByPoliticianKey(politicianKey);
     ElectionsIncumbentsRemoved.DeleteByPoliticianKey(politicianKey);
     ElectionsIncumbentsRemoved.UpdateRunningMateKeyByRunningMateKey(Empty, politicianKey);
     ElectionsPoliticians.DeleteByPoliticianKey(politicianKey);
     ElectionsPoliticians.UpdateRunningMateKeyByRunningMateKey(Empty, politicianKey);
     OfficesOfficials.DeleteByPoliticianKey(politicianKey);
     OfficesOfficials.UpdateRunningMateKeyByRunningMateKey(Empty, politicianKey);
     PoliticiansImagesBlobs.DeleteByPoliticianKey(politicianKey);
     PoliticiansImagesData.DeleteByPoliticianKey(politicianKey);
     TempEmail.DeleteByPoliticianKey(politicianKey);
 }
Ejemplo n.º 2
0
        // ReSharper disable MemberCanBePrivate.Global
        // ReSharper disable MemberCanBeProtected.Global
        // ReSharper disable UnusedMember.Global
        // ReSharper disable UnusedMethodReturnValue.Global
        // ReSharper disable UnusedAutoPropertyAccessor.Global
        // ReSharper disable UnassignedField.Global

        #endregion ReSharper disable

        public static void DeleteByPoliticianKey(
            string politicianKey, int commandTimeout = -1)
        {
            PoliticiansImagesData.DeleteByPoliticianKey(politicianKey, commandTimeout);
            PoliticiansImagesBlobs.DeleteByPoliticianKey(politicianKey, commandTimeout);
        }
        private static void InvalidatePoliticianImage(string politicianKey)
        {
            // We do this via updates to avoid synchronization problems
            var oldBlobs = PoliticiansImagesBlobs.GetDataByPoliticianKey(politicianKey);

            if (oldBlobs.Count == 1)
            {
                var newBlobs =
                    DB.Vote.PoliticiansImagesBlobs.GetCacheDataByPoliticianKey(politicianKey);
                switch (newBlobs.Count)
                {
                case 1:
                {
                    var oldRow = oldBlobs[0];
                    var newRow = newBlobs[0];
                    oldRow.Profile300  = newRow.Profile300;
                    oldRow.Profile200  = newRow.Profile200;
                    oldRow.Headshot100 = newRow.Headshot100;
                    oldRow.Headshot75  = newRow.Headshot75;
                    oldRow.Headshot50  = newRow.Headshot50;
                    oldRow.Headshot35  = newRow.Headshot35;
                    oldRow.Headshot25  = newRow.Headshot25;
                    oldRow.Headshot20  = newRow.Headshot20;
                    oldRow.Headshot15  = newRow.Headshot15;
                    PoliticiansImagesBlobs.UpdateTable(oldBlobs);
                }
                break;

                case 0:
                    PoliticiansImagesBlobs.DeleteByPoliticianKey(politicianKey);
                    break;
                }
            }
            var oldData = PoliticiansImagesData.GetDataByPoliticianKey(politicianKey);

            if (oldData.Count != 1)
            {
                return;
            }
            var newData =
                DB.Vote.PoliticiansImagesData.GetDataByPoliticianKey(politicianKey);

            switch (newData.Count)
            {
            case 1:
            {
                var oldRow = oldData[0];
                var newRow = newData[0];
                //oldRow.ProfileOriginalContentType = newRow.ProfileOriginalContentType;
                oldRow.ProfileOriginalDate = newRow.ProfileOriginalDate;
                //oldRow.ProfileOriginalWidth = newRow.ProfileOriginalWidth;
                //oldRow.ProfileOriginalHeight = newRow.ProfileOriginalHeight;
                //oldRow.HeadshotContentType = newRow.HeadshotContentType;
                oldRow.HeadshotDate = newRow.HeadshotDate;
                //oldRow.HeadshotWidth = newRow.HeadshotWidth;
                //oldRow.HeadshotHeight = newRow.HeadshotHeight;
                oldRow.HeadshotResizeDate = newRow.HeadshotResizeDate;
                PoliticiansImagesData.UpdateTable(oldData);
            }
            break;

            case 0:
                PoliticiansImagesData.DeleteByPoliticianKey(politicianKey);
                break;
            }
        }