private void SavePolygon(object obj)
 {
     try
     {
         using (var context = new DataContext("dbPolygon"))
         {
             context.Polygons.Add(PolygonItem);
             context.SaveChanges();
         }
         DialogResult = true;
     }
     catch (Exception ex)
     {
         HelpUtilites.ShowFullException(ex);
     }
 }
 private void RefreshGridData()
 {
     try
     {
         _polygons.Clear();
         using (var dtContext = new DataContext("dbPolygon"))
         {
             foreach (var polygon in dtContext.Polygons.Include("Points"))
             {
                 _polygons.Add(polygon);
             }
         }
     }
     catch (Exception ex)
     {
         HelpUtilites.ShowFullException(ex);
     }
 }
 private void UpdatePoints()
 {
     try
     {
         using (var ctx = new DataContext("dbPolygon"))
         {
             var dbPolygon = ctx.Polygons.Include(p => p.Points).Single(p => p.Id == _selectedPolygon.Id);
             foreach (var point in _selectedPolygon.Points)
             {
                 var dbPoitnt = dbPolygon.Points.SingleOrDefault(p => p.Id == point.Id);
                 if (dbPoitnt != null)
                 {
                     ctx.Entry(dbPoitnt).CurrentValues.SetValues(point);
                 }
             }
             ctx.SaveChanges();
         }
         IsPotintsChanged = false;
     }
     catch (Exception ex)
     {
         HelpUtilites.ShowFullException(ex);
     }
 }