public ActionResult BookingForm(BookingData formData) { BookingClient client = new BookingClient(); client.MakeBooking(formData); return(RedirectToAction("Index")); }
static void Main(string[] args) { BookingClient client = new BookingClient(); while (true) { try { BookingData[] bookings = client.ViewBookingsFrom(DateTime.Now); Console.WriteLine("Det finns " + bookings.Length + " bokningar"); BookingData data = new BookingData(); data.Name = Console.ReadLine(); data.EventStartTime = DateTime.Now; data.EventStopTime = DateTime.Now; bool result = client.MakeBooking(data); if (result) { Console.WriteLine("Bokningen lyckades"); } else { Console.WriteLine("Bokningen misslyckades"); } } catch (WebException we) { Console.WriteLine("Tjänsten failade"); Console.ReadLine(); } } }
// GET: Booking public ActionResult Index() { BookingClient client = new BookingClient(); List <BookingData> bookings = client.ViewBookingsFrom(DateTime.Now); return(View(bookings)); }
public async Task <IActionResult> Contact() { ViewData["Message"] = "Your contact page."; BookingClient <string> client = new BookingClient <string>(); ViewData["APIData"] = await client.GetAsync("values"); return(View()); }
//[Fact] public async Task it_books_consignment() { var settings = new BookingSettings(TestSettings.Uid, TestSettings.Key, TestSettings.ClientUri, isTest: true); var sut = new BookingClient(settings); var sender = new Party( "Sender Name", "Address 1", "Address 2", "0123", "Oslo", "NOR", "reference number", "additional info", new Contact("John", "*****@*****.**", "98745612")); var recipient = new Party( "Recipient Name", "Address 1", "Address 2", "0123", "Oslo", "NOR", "reference number", "additional info", new Contact("Tom", "*****@*****.**", "23654789")); var product = new Product("A-POST", "customer number"); var packages = new[] { new Package("correlation ID", 1.0, "Products", new Dimensions(10, 10, 10)) }; var consignment = new Consignment( "correlation ID", DateTime.UtcNow.AddDays(1), new Parties(sender, recipient), product, packages); var result = await sut.BookAsync(consignment); result.Success.Should().BeTrue(); }