public async Task Refresh()
 {
     Model.BookingsChanged += (sender, args) =>
     {
         Device.BeginInvokeOnMainThread(() =>
         {
             BookingsList.Clear();
             foreach (var booking in args.NewBookings)
             {
                 BookingsList.Add(booking);
             }
         });
     };
     await Model.FetchBookings();
 }
Пример #2
0
        public BookingsList GetBookings(int id)
        {
            BookingsList allBookings = new BookingsList();

            using (var con = new NpgsqlConnection(connectionString))
            {
                con.Open();
                using (var cmd = new NpgsqlCommand($"SELECT table_id, hour_booked, date_booked, user_id FROM table_bookings WHERE restaurant_id = {id} AND date_booked IS NOT NULL", con))
                    using (var reader = cmd.ExecuteReader())
                        while (reader.Read())
                        {
                            var bookings = new Bookings
                            {
                                table_id    = reader.GetInt32(0),
                                hour_booked = reader.GetIntOrDefault(1),
                                date_booked = reader.GetString(2),
                                user_id     = reader.GetIntOrDefault(3)
                            };
                            allBookings.bookings.Add(bookings);
                        }
            }
            return(allBookings);
        }
Пример #3
0
 private void AddBooking(Booking booking)
 {
     BookingsList.Add(booking);
     MessageBox.Success("Accommodation has been booked.");
 }