Beispiel #1
0
        private void GetRooms(string key)
        {
            List <RoomModel> roomsList = new List <RoomModel>();

            Action <Dictionary <string, RoomModel> > onValueEvent = null;

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

                    Action onSetValueSuccess = () =>
                    {
                    };

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

                    if (rooms != null)
                    {
                        if (rooms.Count == 0)
                        {
                            roomlist.IsVisible = false;
                            info.IsVisible     = true;
                        }

                        if (rooms.Count != 0 && rooms.Count != roomsList.Count)
                        {
                            roomlist.IsVisible = true;
                            info.IsVisible     = false;
                            roomsList.Clear();

                            foreach (KeyValuePair <string, RoomModel> item in rooms)
                            {
                                if (roomsList.All(d => d.Key != item.Value.Key))
                                {
                                    if (item.Value.Status)
                                    {
                                        roomsList.Add(item.Value);
                                    }
                                }
                            }
                            if (roomsList.Count > 0)
                            {
                                roomlist.ItemsSource  = roomsList;
                                roomlist.IsRefreshing = false;
                            }
                            else
                            {
                                roomlist.IsRefreshing = false;
                            }
                        }
                    }
                    else
                    {
                        roomlist.IsVisible = false;
                        info.IsVisible     = true;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("---> error GetDataFromFirebase " + ex.Message);
                }
            };

            _firebaseDatabase.GetRooms("rooms", key, onValueEvent);
        }