Beispiel #1
0
        public static Day getByDayID(int dayID)
        {
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            Day day = new Day();

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                day = (from d in conn.Table<Day>()
                        where d.DayID == dayID
                        select d
                         ).ToList().FirstOrDefault();
            }
            return day;
        }
Beispiel #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var parameter = e.Parameter as HaveMealClass;
            _day = parameter.Day;
            _kind = parameter.Kind;
            //get eats

            cbMeal.ItemsSource = MealDB.getAll();
            cbMeal.DisplayMemberPath = "Name";
            cbMeal.SelectedValuePath = "MealID";

            cbMeal.SelectedIndex = 0;


        }
Beispiel #3
0
        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();

            }



        }
Beispiel #4
0
        public void getStorageInfo()
        {

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            if (localSettings.Values["userID"] != null)
            {
                int userID = (int)localSettings.Values["userID"];
                user = UserDB.getByUserID(userID);
            }
            if (localSettings.Values["dayID"] != null)
            {
                int dayID = (int)localSettings.Values["dayID"];
                _day = DayDB.getByDayID(dayID);
            }


            if (user != null)
                helloUser.Text = "Hello, " + user.Name + "!";

        }
Beispiel #5
0
 public DayDB(Day Day)
 {
     this._Day = Day;
 }
Beispiel #6
0
 public HaveMealClass(Day day, string kind)
 {
     _day = day;
     _kind = kind;
 }