public MealSuggestions()
        {
            this.InitializeComponent();

            _mealSuggestionViewModel = new MealSuggestionViewModel();
            _mealSuggestions = _mealSuggestionViewModel.GetMeals();
            MealSuggestionsGridView.ItemsSource = _mealSuggestions;
            AcceptMealSuggestions_AppBarButton.IsEnabled = false;
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter != null)
     {
         if (e.Parameter is MealViewModel)
         {
             _meal = e.Parameter as MealViewModel;
         }
         else if (e.Parameter is MealSuggestionViewModel)
         {
             _mealSuggestion = null;
         }
     }
 }
 private void AddMealSuggestions_AppBarButton_Click(object sender, RoutedEventArgs e)
 {
     _mealSuggestion = new MealSuggestionViewModel();
     this.Frame.Navigate(typeof(MealItemsByCategory), _mealSuggestion);
 }
 private void textBlock_SelectionChanged(object sender, RoutedEventArgs e)
 {
     if (MealSuggestionsGridView.SelectedItems.Count > 0)
     {
         AcceptMealSuggestions_AppBarButton.IsEnabled = true;
         _mealSuggestion = (MealSuggestionViewModel)MealSuggestionsGridView.SelectedItem;
     }
 }
        public ObservableCollection<IMealViewModel> GetMeals()
        {
            ObservableCollection<IMealViewModel> mealSuggestions =
                new ObservableCollection<IMealViewModel>();

            using (var db = new SQLite.SQLiteConnection(App.DBPath))
            {
                var query = db.Table<MealSuggestion>().OrderBy(c => c.Id);
                foreach (var _mealSuggestion in query)
                {
                    var mealSuggestion = new MealSuggestionViewModel()
                    {
                        Id = _mealSuggestion.Id,
                        CategoryId = _mealSuggestion.CategoryId,
                        MealItemIDsWithWeight =
                            (Dictionary<float, float>)_dictionaryConverterFloat.ConvertBack(_mealSuggestion.MealItemIDsWithWeight, null, null, "")
                    };

                    mealSuggestions.Add(mealSuggestion);
                }
            }

            return mealSuggestions;
        }
        public IMealViewModel GetMeal(int mealId)
        {
            var mealSuggestion = new MealSuggestionViewModel();
            using (var db = new SQLite.SQLiteConnection(App.DBPath))
            {
                var _mealSuggestion = (db.Table<MealSuggestion>().Where(
                    c => c.Id == mealId)).Single();
                mealSuggestion.Id = _mealSuggestion.Id;
                mealSuggestion.CategoryId = _mealSuggestion.CategoryId;
                mealSuggestion.MealItemIDsWithWeight =
                    (Dictionary<float, float>)_dictionaryConverterFloat.ConvertBack(_mealSuggestion.MealItemIDsWithWeight, null, null, "");
            }

            return mealSuggestion;
        }