private void AddCustomer_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            foreach (var features in Geo_Features_Context.GEOGRAPHIC_FEATURES.Local.ToList())
            {
                if (features.WAYPOINT_ID == 0)
                {
                    Geo_Features_Context.GEOGRAPHIC_FEATURES.Remove(features);
                }
            }
            try
            {
                Geo_Features_Context.SaveChanges();
                DataChangedEventHandler handler = DataChanged;
                if (handler != null)
                {
                    handler(this, new EventArgs());
                }
                WaypointIDTextBox.IsEnabled = false;
            }
            catch (DbUpdateException ex)
            {
                var sb = new StringBuilder();
                sb.AppendLine("DbUpdateException error details - {ex?.InnerException?.InnerException?.Message}");

                foreach (var eve in ex.Entries)
                {
                    sb.AppendLine("Entity of type {eve.Entity.GetType().Name} in state {eve.State} could not be updated");
                }



                var error = sb.ToString();
                MessageBox.Show(error);
                //throw;
            }
            catch (Exception ex1)
            {
                var error1 = ex1.ToString();
                MessageBox.Show(error1);
            }
        }
示例#2
0
        private void SaveChangesGeoFeatures()
        {
            foreach (var Feature in Geo_Context.GEOGRAPHIC_FEATURES.Local.ToList())
            {
                if (Feature.ID == 0)
                {
                    Geo_Context.GEOGRAPHIC_FEATURES.Remove(Feature);
                }
            }

            try
            {
                Geo_Context.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                var sb = new StringBuilder();
                sb.AppendLine("DbUpdateException error details - {ex?.InnerException?.InnerException?.Message}");

                foreach (var eve in ex.Entries)
                {
                    sb.AppendLine("Entity of type {eve.Entity.GetType().Name} in state {eve.State} could not be updated");
                }



                var error = sb.ToString();
                MessageBox.Show(error);
                //throw;
            }
            catch (Exception ex1)
            {
                var error1 = ex1.ToString();
                MessageBox.Show(error1);
            }
        }