public AddSpatialWrapper(Street s, double x1, double x2, double y1, double y2)
        {
            Street = s;
            X = x1;
            X2 = x2;

            Y = y1;
            Y2 = y2;
        }
 //sets name of ellipse corresponding to the data of the location
 private void setEllNameFromStreetData(Street locData, Line ell)
 {
     ell.Name = "street_" + locData.Id + "_" + locData.Name;
 }
        private Street getStreetDataFromEllName(String lineName)
        {
            Street retStreet = new Street();
            String[] splittedEllName = lineName.Split('_');
            int parsedId;

            int.TryParse(splittedEllName[1], out parsedId);
            retStreet.Id = parsedId;
            retStreet.Name = splittedEllName[2];

            return retStreet;
        }
        private void canSpatialData_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Point currentMousePos = e.GetPosition(this.canSpatialData);

            if (this.IsDragAndDropActive == true)
            {
                if (this.currentSpatialObjectSelected is Ellipse) //is city
                {
                    Location locToUpdate = this.getLocationDataFromEllName(this.currentSpatialObjectSelected.Name);

                    WebserviceManager.UpdateLocation(locToUpdate, Math.Round(currentMousePos.X, 2), Math.Round(currentMousePos.Y, 2));
                }
                else if (this.currentSpatialObjectSelected is Line) //is street
                {
                    Street locToUpdate = this.getStreetDataFromEllName(this.currentSpatialObjectSelected.Name);

                    WebserviceManager.UpdateStreet(locToUpdate, Math.Round(((Line)this.currentSpatialObjectSelected).X1, 2), Math.Round(((Line)this.currentSpatialObjectSelected).Y1, 2),
                        Math.Round(((Line)this.currentSpatialObjectSelected).X2, 2), Math.Round(((Line)this.currentSpatialObjectSelected).Y2, 2));
                }

                this.IsDragAndDropActive = false;
            }
            else
            {
                if (this.currentSpatialInsertType == EnumSpatialType.STREET) //set end point of street and insert street to db
                {
                    Point streetEndPoint = currentMousePos;
                    Street insertedStr = new Street();
                    insertedStr.Name = this.tbNameOfObject.Text;

                    insertedStr.Id = WebserviceManager.AddStreet(insertedStr, Math.Round(this.StreetStartPoint.X, 2), Math.Round(this.StreetStartPoint.Y, 2),
                        Math.Round(streetEndPoint.X, 2), Math.Round(streetEndPoint.Y, 2));

                    setEllNameFromStreetData(insertedStr, this.DrawingLine);
                    this.IsDrawingStreet = false;
                }
            }
        }
 public static void UpdateStreet(Street street, double x1, double y1, double x2, double y2)
 {
     PUT(Uri + "/rest/streets", JsonConvert.SerializeObject(new AddSpatialWrapper(street, x1, x2, y1, y2)));
 }
        public static int AddStreet(Street street, double x1, double y1, double x2, double y2)
        {
            WebResponse resp = POST(Uri + "/rest/streets", JsonConvert.SerializeObject(new AddSpatialWrapper(street, x1, x2, y1, y2)));

            String id = new StreamReader(resp.GetResponseStream()).ReadToEnd();
            return int.Parse(JsonConvert.DeserializeObject<String>(id));
        }