public void updateDay()
        {

           // _day = null;
            if (this._day == null || (this._day.Date.Date.Year != DateTime.Now.Date.Year || this._day.Date.Date.DayOfYear != DateTime.Now.Date.DayOfYear))
            {
                //create day

                this._day = new Day();
                this._day.User = this.user;
                this._day.Date = DateTime.Now;
                this._day.LastMeal = (int)DateTime.Now.TimeOfDay.TotalMinutes;
                
                DayDB ddb = new DayDB(this._day);

                ddb.save();

                var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                localSettings.Values["dayID"] = _day.DayID;

                List<Eat> eats = new List<Eat> { };
                eats.Add(new Eat(_day.DayID, "Breakfest"));
                eats.Add(new Eat(_day.DayID, "Lunch"));
                eats.Add(new Eat(_day.DayID, "Dinner"));

                foreach(Eat e in eats)
                {
                    EatDB edb = new EatDB(e);
                    edb.save();
                }

                this.tbDate.Text = DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString();

                //Update meals from servers everyday
                NetworkService.updateMeals();

            }



        }
        private void btnHave_Click(object sender, RoutedEventArgs e)
        {

            //get eat from day by kind
            Meal meal = (Meal)cbMeal.SelectedItem;

            if (!_kind.Equals("Snack"))
            {
                Eat eat = EatDB.getByDayID(_day.DayID).Where(et => et.Kind == _kind).First() as Eat;
                eat.Time = DateTime.Now;
                eat.Done = true;
                eat.MealID = meal.MealID;
                EatDB edb = new EatDB(eat);
                edb.save();

            }
            else
            {
                Eat eat = new Eat();
                eat.Time = DateTime.Now;
                eat.Done = true;
                eat.MealID = meal.MealID;
                eat.Kind = "Snack";
                EatDB edb = new EatDB(eat);
                edb.save();
            }

            _day.Energy += meal.Energy;
            _day.Fat += meal.Fat;
            _day.Saturates += meal.Saturates;
            _day.Sugars += meal.Sugar;
            _day.Salt += meal.Salt;

            DayDB ddb = new DayDB(_day);
            ddb.save();



            Frame.Navigate(typeof(MainPage));
        }