Example #1
0
        public static HttpResponseMessage PostBooking(Model.BookingModel booking)
        {
            var    bookingUrl  = URL;
            string requestBody = JsonConvert.SerializeObject(booking);

            using (var httpClient = new HttpClient())
            {
                using (HttpRequestMessage request = new HttpRequestMessage {
                    RequestUri = new Uri(bookingUrl), Method = HttpMethod.Post
                })
                {
                    request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
                    //request.Headers.Add("Content-Type", "application/json");
                    request.Headers.Add("Accept", "application/json");
                    var response = httpClient.SendAsync(request).Result;
                    // IsOKResponse(response);
                    return(response);
                }
            }
        }
Example #2
0
        public static Model.BookingModel GetBooking(Table table)
        {
            dynamic data         = table.CreateDynamicInstance();
            var     checkinDate  = (DateTime)data.checkin;
            var     checkoutDate = (DateTime)data.checkout;

            //body
            var booking = new Model.BookingModel
            {
                firstname    = (string)data.firstname,
                lastname     = (string)data.lastname,
                totalprice   = (int)data.totalprice,
                depositpaid  = (bool)data.depositpaid,
                bookingdates = new Model.BookingDates()
                {
                    checkin  = new DateTime(checkinDate.Year, checkinDate.Month, checkinDate.Day),
                    checkout = new DateTime(checkoutDate.Year, checkoutDate.Month, checkoutDate.Day)
                }
            };

            return(booking);
        }