internal static ClientResponseObject getBodiesOfTomb(Tomb tomb)
        {
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(SERVER_LINK + "/tomb/" + tomb.tombId + "/body");
                request.Method = "GET";
                request.ContentType = "application/json";
                request.CookieContainer = new CookieContainer();
                request.CookieContainer.Add(new Uri(SERVER_LINK + "/tomb"),
                new Cookie("JSESSIONID", JSESSIONID));
                request.CookieContainer.Add(new Uri(SERVER_LINK + "/tomb"),
                new Cookie("CIMITERO_AUTH_TOKEN", CIMITERO_AUTH_TOKEN));

                try
                {
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    {
                        Console.WriteLine(response.Headers.Keys);
                        StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                        string json = reader.ReadToEnd();
                        JObject jObject = JObject.Parse(json);

                        if (Boolean.Parse(jObject["ok"].ToString()))
                        {
                            JToken jArray = jObject["items"];
                            JToken jBodies = jArray["items"];
                            List<Body> bodies = JsonConvert.DeserializeObject<List<Body>>(jBodies.ToString());
                            return new ClientResponseObject(Boolean.Parse(jObject["ok"].ToString()), "", bodies);
                        }
                        else
                        {
                            return new ClientResponseObject(Boolean.Parse(jObject["ok"].ToString()), extractErrorsFromResponse(jObject));
                        }
                    }
                }
                catch (WebException ex)
                {
                    return new ClientResponseObject(false, ex.Message);
                }
            }

            #endregion


        }
        public CimiteroEditor(Tomb tombToShow)
        {
            InitializeComponent();
            this.tmpTomb = tombToShow;
            points = new List<Point>();
            points_street = new List<Point>();
            drawMode = "Bounding";

            cro = CommunicationController.getBoundaryCoordinates(CommunicationController.getSelectedCemetryGround());
            if (cro.ok)
            {

                for (int i = 0; i < cro.boundaryCoordinates.Count; i++)
                {
                    Line line = new Line();
                    line.Stroke = Brushes.Black;

                    if (i + 1 < cro.boundaryCoordinates.Count)
                    {
                        line.X1 = cro.boundaryCoordinates[i].x;
                        line.X2 = cro.boundaryCoordinates[i + 1].x;
                        line.Y1 = cro.boundaryCoordinates[i].y;
                        line.Y2 = cro.boundaryCoordinates[i + 1].y;
                    }
                    else
                    {
                        line.X1 = cro.boundaryCoordinates[i].x;
                        line.X2 = cro.boundaryCoordinates[0].x;
                        line.Y1 = cro.boundaryCoordinates[i].y;
                        line.Y2 = cro.boundaryCoordinates[0].y;
                    }
                    line.StrokeThickness = 10;
                    cimitero_canvas.Children.Add(line);
                    points.Add(new Point(cro.boundaryCoordinates[i].x, cro.boundaryCoordinates[i].y));

                }

                cro = CommunicationController.getTrackCoordinates(CommunicationController.getSelectedCemetryGround());
                if (cro.ok)
                {
                    for (int i = 0; i < cro.boundaryCoordinates.Count; i++)
                    {
                        Line line = new Line();
                        line.Stroke = Brushes.Green;

                        if (i + 1 < cro.boundaryCoordinates.Count)
                        {
                            line.X1 = cro.boundaryCoordinates[i].x;
                            line.X2 = cro.boundaryCoordinates[i + 1].x;
                            line.Y1 = cro.boundaryCoordinates[i].y;
                            line.Y2 = cro.boundaryCoordinates[i + 1].y;
                        }

                        line.StrokeThickness = 10;
                        cimitero_canvas.Children.Add(line);
                        points_street.Add(new Point(cro.boundaryCoordinates[i].x, cro.boundaryCoordinates[i].y));
                    }

                    cro = CommunicationController.getTombCoordinates(CommunicationController.getSelectedCemetryGround());
                    if (cro.ok)
                    {
                        for (int x = 0; x < cro.tombCoordinates.Count; x++)
                        {

                            System.Windows.Shapes.Rectangle rect;
                            rect = new System.Windows.Shapes.Rectangle();
                            rect.Stroke = new SolidColorBrush(Colors.Black);
                            if (tmpTomb != null)
                            {
                                if (cro.tombCoordinates[x].tombNo == tmpTomb.tombNo)
                                {
                                    rect.Fill = new SolidColorBrush(Colors.DarkGreen);
                                }
                                else
                                {
                                    rect.Fill = new SolidColorBrush(Colors.LavenderBlush);
                                }
                            }
                            else
                            {
                                rect.Fill = new SolidColorBrush(Colors.LavenderBlush);
                            }

                            if (cro.tombCoordinates[x].isSupersized)
                                rect.Width = 60;
                            else
                                rect.Width = 30;

                            rect.Height = 30;

                            Canvas.SetLeft(rect, cro.tombCoordinates[x].x);
                            Canvas.SetTop(rect, cro.tombCoordinates[x].y);
                            this.cimitero_canvas.Children.Add(rect);

                            TextBlock textBlock = new TextBlock();
                            textBlock.Text = cro.tombCoordinates[x].tombNo;
                            textBlock.Foreground = Brushes.Red;
                            Canvas.SetLeft(textBlock, cro.tombCoordinates[x].x);
                            Canvas.SetTop(textBlock, cro.tombCoordinates[x].y);
                            cimitero_canvas.Children.Add(textBlock);

                            this.points_tomb.Add(new TombCoords(cro.tombCoordinates[x].x, cro.tombCoordinates[x].y, cro.tombCoordinates[x].isSupersized, cro.tombCoordinates[x].tombNo));

                        }
                    }
                    else
                    {
                        MessageBox.Show(cro.message, "Cimitero© Error ", MessageBoxButton.OK, MessageBoxImage.Hand);
                    }
                }
                else
                {
                    MessageBox.Show(cro.message, "Cimitero© Error ", MessageBoxButton.OK, MessageBoxImage.Hand);
                }

            }
            else
            {
                MessageBox.Show(cro.message, "Cimitero© Error ", MessageBoxButton.OK, MessageBoxImage.Hand);
            }

            this.bttn_grab.Background = Brushes.White;
            this.bttn_bounding.Background = Brushes.Green;
            this.bttn_street.Background = Brushes.White;
        }
        private void datagrid_Tombs_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (datagrid_Tombs.SelectedItem != null)
            {
                if (this.datagrid_Tombs.SelectedItem != null)
                {
                    Tomb selectedTomb = (Tomb)datagrid_Tombs.SelectedItem;
                    tmpselectedTomb = selectedTomb;
                    cro = CommunicationController.getBillsOfTomb(selectedTomb);
                    if (cro.ok)
                    {
                        this.table_Bills1.ItemsSource = cro.invoices;
                    }
                    else
                    {
                        MessageBox.Show(cro.message, "Cimitero© Error ", MessageBoxButton.OK, MessageBoxImage.Hand);
                    }
                    cro = CommunicationController.getBodiesOfTomb(selectedTomb);
                    if (cro.ok)
                    {
                        this.table_bodies.ItemsSource = cro.bodies;

                    }
                    else
                    {
                        MessageBox.Show(cro.message, "Cimitero© Error ", MessageBoxButton.OK, MessageBoxImage.Hand);
                    }
                    cro = CommunicationController.getCustomerOfTomb(selectedTomb);
                    if (cro.ok)
                    {
                        Customer tmpCustomer = cro.customer[0];
                        this.lbl_title.Content = tmpCustomer.title + " " + tmpCustomer.firstName + " " + tmpCustomer.lastName;
                        this.lbl_address.Content = tmpCustomer.address;
                        this.lbl_birthdate.Content = tmpCustomer.gebDatum;
                        this.lbl_telephone.Content = tmpCustomer.telephoneNumber;

                    }
                    else
                    {
                        MessageBox.Show(cro.message, "Cimitero© Error ", MessageBoxButton.OK, MessageBoxImage.Hand);
                    }
                    showPartial(this.tombDetail);

                }
                else
                {
                    MessageBox.Show("No Tomb selected", "Cimitero© Error ", MessageBoxButton.OK, MessageBoxImage.Hand);
                }
            }
        }