예제 #1
0
        private dynamic EndTrip(string tripId)
        {
            var responseNegotiator = Negotiate.WithHeader("Content-Type", "application/json");

            try
            {
                var endTripRequest = JsonConvert.DeserializeObject <dynamic>(Request.Body.AsString());
                var endLocation    = new GeoCoordinate((double)endTripRequest.EndLocation.Latitude, (double)endTripRequest.EndLocation.Longitude);
                var endTime        = DateTime.Parse(endTripRequest.EndTime.ToString());
                TripService.EndTrip(tripId, endLocation, endTime);
                responseNegotiator.WithModel("Trip ended succesfully").WithStatusCode(HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                responseNegotiator.WithModel(ex.Message).WithStatusCode(HttpStatusCode.InternalServerError);
            }
            return(responseNegotiator);
        }