Beispiel #1
0
        private void GetBookings()
        {
            List <BookRoomModel> bookedTickets = new List <BookRoomModel>();

            Action <Dictionary <string, BookRoomModel> > onValueEvent = (Dictionary <string, BookRoomModel> tickets) =>
            {
                try
                {
                    System.Diagnostics.Debug.WriteLine("---> EVENT GetDataFromFirebase ");

                    Action onSetValueSuccess = () =>
                    {
                    };

                    Action <string> onSetValueError = (string errorDesc) =>
                    {
                    };

                    if (tickets != null)
                    {
                        info.IsVisible = false;

                        if (tickets.Count != 0 && tickets.Count != bookedTickets.Count)
                        {
                            bookedTickets.Clear();

                            foreach (KeyValuePair <string, BookRoomModel> item in tickets)
                            {
                                if (bookedTickets.All(d => d.Key != item.Value.Key))
                                {
                                    bookedTickets.Add(item.Value);
                                }
                            }

                            bookingsList.IsRefreshing = false;
                            bookingsList.ItemsSource  = bookedTickets;
                        }
                    }
                    else
                    {
                        bookedTickets.Clear();
                        bookingsList.IsRefreshing = false;
                        bookingsList.IsVisible    = false;
                        info.IsVisible            = true;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("---> error GetDataFromFirebase " + ex.Message + " , Source" + ex.Source);
                    throw;
                }
            };

            _firebaseDatabase.GetBookedHotels("hotelbookings", onValueEvent);
        }