예제 #1
0
 public Traveler Add(Traveler item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     else
     {
         context.Travelers.Add(item);
         context.SaveChanges();
         RefreshTravelerList();
         return item;
     }
 }
예제 #2
0
 public HttpResponseMessage PostTraveler(Traveler newTraveler)
 {
     if (!ModelState.IsValid)
     {
         throw new HttpResponseException(HttpStatusCode.BadRequest);
     }
     else
     {
         newTraveler = repo.Add(newTraveler);
         var response = Request.CreateResponse(HttpStatusCode.Created, newTraveler);
         return response;
     }
 }