private void UpdateAll(FeedbackContainerControl feedback)
        {
            try
            {
                var errorCount = 0;

                foreach (var updateAll in _UpdateAllList)
                {
                    errorCount += updateAll(false);
                }

                feedback.AddInfo(_UpdateCount.ToString(CultureInfo.InvariantCulture) +
                                 _UpdateCount.Plural(" item was", " items were") + " updated.");
                if (errorCount > 0)
                {
                    feedback.AddError(errorCount.ToString(CultureInfo.InvariantCulture) +
                                      errorCount.Plural(" item was", " items were") +
                                      " not updated due to errors.");
                }
            }
            catch (Exception ex)
            {
                feedback.HandleException(ex);
            }
        }
Beispiel #2
0
        private void UpdateAll(FeedbackContainerControl feedback)
        {
            try
            {
                var errorCount = 0;

                var oldEmail = Politicians.GetPublicEmail(PoliticianKey);
                foreach (var updateAll in _UpdateAllList)
                {
                    errorCount += updateAll(false);
                }
                var newEmail = Politicians.GetPublicEmail(PoliticianKey);
                if (oldEmail != newEmail)
                {
                    LoadContactTabData();
                    UpdatePanelContact.Update();
                    LoadSocialMediaTabData();
                    UpdatePanelSocial.Update();
                }

                feedback.AddInfo(_UpdateCount.ToString(CultureInfo.InvariantCulture) +
                                 _UpdateCount.Plural(" item was", " items were") + " updated.");
                if (errorCount > 0)
                {
                    feedback.AddError(errorCount.ToString(CultureInfo.InvariantCulture) +
                                      errorCount.Plural(" item was", " items were") +
                                      " not updated due to errors.");
                }
            }
            catch (Exception ex)
            {
                feedback.HandleException(ex);
            }
        }
Beispiel #3
0
        internal static int UpdateAll(IEnumerable <DataItemBase> items,
                                      FeedbackContainerControl feedback, bool showSummary = true,
                                      UpdatePanel updatePanel = null)
        {
            var errorCount = 0;

            try
            {
                var updateCount = 0;
                var changed     = false;

                foreach (var item in items)
                {
                    var updateStatus = item.DoUpdate(false);
                    switch (updateStatus)
                    {
                    case SecurePage.UpdateStatus.Failure:
                        errorCount++;
                        changed = true;
                        break;

                    case SecurePage.UpdateStatus.Success:
                        changed = true;
                        updateCount++;
                        break;
                    }
                }
                if (changed)
                {
                    updatePanel?.Update();
                }
                if (showSummary)
                {
                    //if (updateCount > 1)
                    feedback.AddInfo(updateCount.ToString(CultureInfo.InvariantCulture) +
                                     updateCount.Plural(" item was", " items were") + " updated.");
                    if (errorCount > 0)
                    {
                        feedback.AddError(errorCount.ToString(CultureInfo.InvariantCulture) +
                                          errorCount.Plural(" item was", " items were") +
                                          " not updated due to errors.");
                    }
                }
            }
            catch (Exception ex)
            {
                feedback.HandleException(ex);
            }

            return(errorCount);
        }