public async Task <HttpResponseMessage> PatchDeliveryLocation(
            [HttpTrigger(AuthorizationLevel.Function, "patch", Route = "Delivery/{id}/Location")] HttpRequest req, string id)
        {
            string token = req.Headers["Authorization"].ToString().Replace("Bearer ", "");

            if (_authorizationsService.IsTokenValid(token, false))
            {
                Deliverer deliverer = await _deliverersService.GetDelivererByToken(token);

                if (deliverer == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.Unauthorized));
                }
                // Getting data from JSON and putting it in a LatLng object
                StreamReader r           = new StreamReader(req.Body);
                string       requestBody = await r.ReadToEndAsync();

                r.Dispose(); // Dispose StreamReader so it cannot be used anymore
                dynamic data = JsonConvert.DeserializeObject <dynamic>(requestBody);

                //Get info and fron data and parameter
                LatLng latLng     = new LatLng((double)data?.latitude, (double)data?.longitude);
                Guid   deliveryId = Guid.Parse(id);

                // Get Google API key
                dynamic config = JsonConvert.DeserializeObject(File.ReadAllText("../../../../BezorgDirect.BezorgersApplicatie.API/variables.json"));
                string  apiKey = config["LocationsService"]["GoogleMapsApiKey"];

                // Creating location object from LatLng object and AddressData object
                AddressData addressData = await _locationsService.GetAddressFromLatLong(latLng, apiKey);

                Location l = new Location(Guid.NewGuid(), latLng.Latitude, latLng.Longitude, addressData.Address, addressData.PostalCode, addressData.Place, false);

                // If Location exists, replace it with existing one
                if (await _locationsService.DoesLocationExist(latLng.Latitude, latLng.Longitude, false))
                {
                    l = await _locationsService.GetLocationByLatLong(latLng.Latitude, latLng.Longitude, false);
                }
                // Getting logged in deliverer and the CurrentDelivery to patch
                Delivery result = await _deliveriesService.PatchDeliveryLocation(await _deliveriesService.GetDelivery(deliveryId), l);

                return(result != null
                    ? new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(JsonConvert.SerializeObject(result), Encoding.UTF8, "application/json")
                }
                    : new HttpResponseMessage(HttpStatusCode.BadRequest));
            }
            // Authorized access only
            return(new HttpResponseMessage(HttpStatusCode.Unauthorized));
        }