/// <summary> /// Save Booking to the database /// </summary> public SwiftBooking SaveBooking(SwiftBooking booking) { bookingRepository.Add(booking); bookingRepository.SaveChanges(); return(booking); }
public string Deliver(SwiftBooking request) { if (ModelState.IsValid) { return(bookingService.Deliver(request)); } throw new InvalidOperationException("reqest invalid"); }
public SwiftBooking SaveBooking(SwiftBooking request) { if (ModelState.IsValid) { return(bookingService.SaveBooking(request)); } throw new InvalidOperationException("reqest invalid"); }
public string Deliver(SwiftBooking booking) { RestRequest restRequest = new RestRequest { Method = Method.POST, RequestFormat = DataFormat.Json }; restRequest.AddBody(booking.MapToApi()); return(restClient.Execute(Path.Combine(ApiHostname, ApiEndpoint), restRequest).Content); }
public void SaveBookingTest() { //Setup var booking = new SwiftBooking { Address = "Perennial Dr", Id = 0, Name = "test" }; bookingRepositoryMock.Setup(br => br.Add(booking)); bookingRepositoryMock.Setup(br => br.SaveChanges()); //Act var results = testSubject.SaveBooking(booking); //Assert bookingRepositoryMock.VerifyAll(); swiftRestClientMock.VerifyAll(); Assert.AreEqual(results.Name, booking.Name); Assert.AreEqual(results.Address, booking.Address); }