public static void UpdateRoutes(Route CurrentRoute)
        {
            var Routes = RoutesRepo.GetRoutes();

            if (Routes != null)
            {
                if (Routes.Count > 0)
                {
                    CurrentRoute.Id = Routes[Routes.Count - 1].Id + 1;
                }
            }
            else
            {
                Routes = new ObservableCollection <Route>();
            }
            Routes.Add(CurrentRoute);

            var json = JsonConvert.SerializeObject(Routes);


            File.WriteAllText("Routes.json", json);
        }
        private void TimerForCarAnimation_Tick(object sender, EventArgs e)
        {
            if (routeResult.Locations.Count == 0)
            {
                return;
            }


            if (TempIndexForLocationCollection == 0)
            {
                MyMap.SetView(routeResult.Locations, new Thickness(200), 0);
            }



            // Dongelerde mashinin istiqametini mueyyen etmek ucun
            if (TempIndexForLocationCollection != routeResult.Locations.Count)
            {
                for (int i = 0; i < routeResult.ManeuverPointsForDegreesAnimation.Count; i++)
                {
                    if (routeResult.ManeuverPointsForDegreesAnimation[i] == routeResult.Locations[TempIndexForLocationCollection])
                    {
                        CarRotateForDegreeAnimation = routeResult.RoutePathForDegreesAnimation[i] + 93;
                        routeResult.ManeuverPointsForDegreesAnimation.RemoveAt(i); // keciymiz yollari silirem.
                        routeResult.RoutePathForDegreesAnimation.RemoveAt(i);
                        break;
                    }
                }



                foreach (var child in MyMap.Children)
                {
                    if (child is Pushpin updateTaxiLocation) // Taxi going
                    {
                        if (updateTaxiLocation.Tag?.ToString() == CurrentRoute.Driver.Id.ToString())
                        {
                            MyMap.Children.Remove(updateTaxiLocation);

                            updateTaxiLocation.Location = routeResult.Locations[TempIndexForLocationCollection];
                            updateTaxiLocation.Template = Application.Current.FindResource("TaxiPushpin") as ControlTemplate;
                            MapLayer.SetPositionOffset(updateTaxiLocation, new Point(0, 20));
                            MyMap.Children.Add(updateTaxiLocation);
                            break;
                        }
                    }
                }


                //foreach (var child in myMap.Children)
                //{
                //    if (child is MapPolyline RoutePolyline)
                //    {
                //        RoutePolyline.Locations.RemoveAt(TempIndexForLocationCollection);
                //    }
                //}

                CurrentRoute.Driver.Location = routeResult.Locations[TempIndexForLocationCollection];
                TempIndexForLocationCollection++;
            }
            else
            {
                if (DriverWaiting)
                {
                    ClearFunc();
                    GetAPIResultService.GetRoutePoints(GetCurrentLocationService.CurrentLocation(), DestinationLocation, routeResult);

                    //Add Polyline ( RoutePath )
                    MapPolyline.Locations = routeResult.Locations;
                    MyMap.Children.Add(MapPolyline);
                    MyMap.Children.Add(new Pushpin()
                    {
                        Location = DestinationLocation, ToolTip = GetAPIResultService.CurrentLocationAddressName(DestinationLocation).ToString()
                    });

                    DriverWaiting = false;
                    TimerForCarAnimation.Start();
                }
                else
                {
                    EndRouteView RatingView = new EndRouteView();

                    RatingView.ShowDialog();



                    WriteToFileService.UpdateRoutes(CurrentRoute);

                    WriteToFileService.UpdateDrivers(DriversVM, RatingView.Endvm.RatingValue, CurrentRoute.Driver);


                    History = RoutesRepo.GetRoutes();

                    ClearFunc();
                }
            }
        }