public static void UpdateGeographyKoord(int idUpdate, int srid, int radiusAction, decimal heighSeaLevel, string description, string typeKoordinates, params double[] latitude_longitude) { var context = new FastWaterContext(); //Объект класса для получения доступа к сущностям DbGeography geographyKoords = null; switch (typeKoordinates) { case "POINT": geographyKoords = CreatePoint(latitude_longitude[0], latitude_longitude[1]); break; case "LINESTRING": geographyKoords = CreateLineString(latitude_longitude[0], latitude_longitude[1], latitude_longitude[2], latitude_longitude[3]); break; case "POLYGON": geographyKoords = CreatePoligon(latitude_longitude); break; // case MessageBox.Show("Не верный тип координат"); } IQueryable <GeographicalKoordinate> query = context.GeographicalKoordinates; var updateObject = query.FirstOrDefault(x => x.Id_GeographicalKoordinates == idUpdate); updateObject.Koordinate = geographyKoords; updateObject.SRID = srid; updateObject.RadiusAction = radiusAction; updateObject.HeighSeaLevel = heighSeaLevel; updateObject.description = description; updateObject.TypeKoordinates = typeKoordinates; context.Entry(updateObject).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public static void UpdatePost(int idUpdate, string namePost, decimal distanceSensors, int IdKoords, string nameBasin, string nameGround, string nameLocality, string description) { var context = new FastWaterContext(); //Объект класса для получения доступа к сущностям GeographicalKoordinate koordinate = GeographyKordinatesService.GetGeographicalKoordinatesEf().FirstOrDefault(y => y.Id_GeographicalKoordinates == IdKoords); Basin basin = context.Basins.FirstOrDefault(y => y.NameBasin.Equals(nameBasin)); Ground ground = context.Grounds.FirstOrDefault(y => y.TypeGround.Equals(nameGround)); Locality locality = context.Localities.FirstOrDefault(y => y.NameLocality.Equals(nameLocality)); IQueryable <Post> query = context.Posts; var updateObject = query.FirstOrDefault(x => x.Id_Post == idUpdate); updateObject.NamePost = namePost; updateObject.DistanceBeetwenSensors = distanceSensors; updateObject.GeographicalKoordinate = koordinate; updateObject.Basin = basin; updateObject.Ground = ground; updateObject.Locality = locality; updateObject.description = description; context.Entry(updateObject).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }