private MealDocument ParseFirebaseResultToMealDocument(object result)
        {
            var snapshot = (QuerySnapshot)result;

            if (!snapshot.IsEmpty)
            {
                var          document     = snapshot.Documents[0];
                MealDocument mealDocument = new MealDocument();
                mealDocument.DocumentId = document.Id;
                foreach (var element in document.Data)
                {
                    var key = element.Key;
                    if (this.defaultMeals.Contains(key))
                    {
                        var listDish = new List <string>();
                        var content  = document.Get(key);

                        var dictio = new JavaDictionary <string, string>(content.Handle, JniHandleOwnership.DoNotRegister);

                        foreach (KeyValuePair <string, string> item in dictio)
                        {
                            listDish.Add(item.Value);
                        }
                        mealDocument.SetMeal(listDish, key);
                    }
                }
                return(mealDocument);
            }
            return(new MealDocument());
        }
Example #2
0
        private void SetMealDocumentFromDocument(DocumentSnapshot document)
        {
            string date   = document?.Data[MealDocument.DateKey]?.ToString() ?? string.Empty;
            string userId = document?.Data[MealDocument.UserKey]?.ToString() ?? string.Empty;

            this.mealDocument = new MealDocument(userId, date);
            var listItemTitle = this.GetItemsTitle();

            foreach (var data in document?.Data)
            {
                var mealContent = new List <string>();
                if (listItemTitle.Contains(data.Key?.ToString()))
                {
                    if (data.Value is NSMutableDictionary dictionary)
                    {
                        foreach (var element in dictionary)
                        {
                            mealContent.Add(element.Value.ToString());
                        }
                        this.mealDocument.SetMeal(mealContent, data.Key?.ToString());
                    }
                    if (data.Key?.ToString() == this.applicationTabBar.SelectedItem.Title)
                    {
                        this.viewSource.Items = mealContent;
                    }
                }
            }
        }
Example #3
0
 private void InitData()
 {
     this.viewSource            = new TableViewSource(new List <string>(), this.DateTimeToDefaultFormat());
     this.viewSource.Identifier = this.applicationTabBar.SelectedItem.Title;
     this.viewSource.DocumentId = DocumentId;
     this.datepicker.Mode       = UIDatePickerMode.Date;
     this.datepicker.SetDate((NSDate)this.currrentDateTime, false);
     this.mealTableView.Source = this.viewSource;
     this.mealDocument         = new MealDocument();
     this.LoadDishesAsync().SafeFireAndForget();
 }