public HttpResponseMessage Post(Trip Trip)
 {
     Trip addedTrip = _dbContext.Trips.Add(Trip);
     var response = new HttpResponseMessage<Trip>(HttpStatusCode.Created);
     response.Headers.Location = new Uri(ControllerContext.Request.RequestUri + addedTrip.Id.ToString());
     return response;
 }
 public HttpResponseMessage Put(Guid id, Trip trip)
 {
     if(_dbContext.Trips.SingleOrDefault(x=>x.Id==id)== null)
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
     _dbContext.Trips.AddOrUpdate(trip);
     _dbContext.SaveChanges();
     return new HttpResponseMessage(HttpStatusCode.NoContent);
 }
Example #3
0
 private static void InsertTrip()
 {
     Trip trip = new Trip
     {
         CostUSD = 800,
         StartDate = new DateTime(2011, 9, 1),
         EndDate = new DateTime(2011, 9, 14)
     };
     using (BreakAwayContext context = new BreakAwayContext())
     {
         context.Trips.Add(trip);
         context.SaveChanges();
     }
 }
Example #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Trips EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTrips(Trip trip)
 {
     base.AddObject("Trips", trip);
 }
Example #5
0
 /// <summary>
 /// Create a new Trip object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="customerId">Initial value of the CustomerId property.</param>
 /// <param name="vehicleId">Initial value of the VehicleId property.</param>
 /// <param name="driverId">Initial value of the DriverId property.</param>
 /// <param name="passengerNum">Initial value of the PassengerNum property.</param>
 /// <param name="dispatchTime">Initial value of the DispatchTime property.</param>
 /// <param name="dispatchLocation">Initial value of the DispatchLocation property.</param>
 /// <param name="returnTime">Initial value of the ReturnTime property.</param>
 public static Trip CreateTrip(global::System.Int32 id, global::System.Int32 customerId, global::System.String vehicleId, global::System.Int32 driverId, global::System.Int32 passengerNum, global::System.DateTime dispatchTime, global::System.String dispatchLocation, global::System.DateTime returnTime)
 {
     Trip trip = new Trip();
     trip.Id = id;
     trip.CustomerId = customerId;
     trip.VehicleId = vehicleId;
     trip.DriverId = driverId;
     trip.PassengerNum = passengerNum;
     trip.DispatchTime = dispatchTime;
     trip.DispatchLocation = dispatchLocation;
     trip.ReturnTime = returnTime;
     return trip;
 }
Example #6
0
 public void Update(Trip trip)
 {
     Trip tripToUpdate = trips.Values.SingleOrDefault(x => x.Id == trip.Id);
     if (tripToUpdate != null)
         tripToUpdate = trip;
 }
Example #7
0
 public Trip Add(Trip trip)
 {
     trips.Add(trip.Id, trip);
     return trip;
 }
 public void Context()
 {
     trip = new Trip { Id = id, Name = "New York spring tour" };
     response = client.Post(trip);
 }