public ActionResult <DeliveryManCurrentLocationDto> AddDeliveryManCurrentLocation([FromBody] DeliveryManCurrentLocationDto location)
        {
            var deliveryMan = deliveryManService.GetDeliveryManById(location.DeliveryManId);

            if (deliveryMan == null)
            {
                return(NotFound());
            }

            var newlocation = _mapper.Map <CurrentLocation>(location);

            var             currentLocation  = currentLocationService.GetDeliveryManCurrentLocation(location.DeliveryManId);
            CurrentLocation locationToReturn = null;

            if (currentLocation == null)
            {
                //This is the first time that the current location will be inserted
                locationToReturn = currentLocationService.AddDeliveryManCurrentLocation(newlocation);
            }
            else
            {
                //The deliveryMan currentLocation will be updated
                currentLocation.Lat  = location.Lat;
                currentLocation.Long = location.Long;

                locationToReturn = currentLocationService.UpdateDeliveryManCurrentLocation(currentLocation);
            }


            return(Ok(_mapper.Map <DeliveryManCurrentLocationDto>(locationToReturn)));
        }
        public ActionResult <DeliveryManCurrentLocationDto> UpdateDeliveryManCurrentLocation([FromBody] DeliveryManCurrentLocationDto location)
        {
            var deliveryMan = deliveryManService.GetDeliveryManById(location.DeliveryManId);

            if (deliveryMan == null)
            {
                return(NotFound());
            }

            var deliveryManCurrentLocation = currentLocationService.GetDeliveryManCurrentLocation(location.DeliveryManId);

            if (deliveryManCurrentLocation == null)
            {
                return(NotFound());
            }

            deliveryManCurrentLocation.Lat  = location.Lat;
            deliveryManCurrentLocation.Long = location.Long;

            var newLocation = currentLocationService.UpdateDeliveryManCurrentLocation(deliveryManCurrentLocation);

            return(Ok(_mapper.Map <DeliveryManCurrentLocationDto>(newLocation)));
        }