/* class functions */ // gets data from db List<Dic<string, object>> and sets it to private variable private async void SetData() { // dummy text for user messageHeader.Text = "Loading messages, please wait!"; // change mouse cursor to load Mouse.OverrideCursor = Cursors.Wait; try { FirebaseHandler fbh = new FirebaseHandler(); CollectionHandler collectionHandler = new CollectionHandler(); this.data = await fbh.GetCollection(collectionHandler.GetMessageCollection()); //release mouse cursor to normal Mouse.OverrideCursor = null; if (this.data[0] != null) { // insert messages to "DOM" or ui this.InsertToDom(this.data[0]); } } catch (Exception e) { messageHeader.Text = "Error occured: " + e.Message; } }
/// <summary> /// Loads news from firestore. /// Controls mouse cursor to show loading. Raises exception if firebase fails. /// </summary> /// <exception cref="Exception">Errors in firebase</exception> private async void GetData() { Mouse.OverrideCursor = Cursors.Wait; try { FirebaseHandler fbh = new FirebaseHandler(); CollectionHandler collectionHandler = new CollectionHandler(); List <Dictionary <string, object> > list1 = await fbh.GetCollection(collectionHandler.GetNewsCollection("fi")); List <Dictionary <string, object> > list2 = await fbh.GetCollection(collectionHandler.GetNewsCollection("en")); this.news.AddRange(list1); this.news.AddRange(list2); Mouse.OverrideCursor = null; this.FillDataCollection(); } catch (Exception e) { _ = MessageBox.Show(e.Message, "There was an error", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary>method <c>ReadSeries</c> Reads series information from firestore. Sets cursor to wait and releases it after data is fetched</summary> private async void ReadSeries() { Mouse.OverrideCursor = Cursors.Wait; FirebaseHandler firebaseHandler = new FirebaseHandler(); List <Dictionary <string, object> > data = await firebaseHandler.GetCollection("series"); List <string> temp = new List <string>(); foreach (Dictionary <string, object> x in data) { x.TryGetValue("name", out object name); temp.Add(name.ToString()); } this.FillDropDown(seriesDropdown, temp.ToArray()); Mouse.OverrideCursor = null; }