Ejemplo n.º 1
0
        public async void save_habit_data(Recurring Habit_, DateTime?occurence_date = null)
        {
            int i = 0;

            if (occurence_date == null)
            {
                occurence_date = Habit_.date_started;
            }
            occurence_date = Convert.ToDateTime(occurence_date);
            DateTime dt = Convert.ToDateTime(occurence_date);

            while (occurence_date <= Habit_.date_ended)
            {
                var Habit_Data_ = new Habit_Data
                {
                    //Job = Habit_,
                    Job_ID       = Habit_.ID,
                    date_run     = dt,
                    money_saved  = Habit_.money_saved,
                    money_stored = Habit_.money_saved,
                    stash_to_use = Habit_.stash_to_use
                };
                await SaveItemAsync(Habit_Data_);

                occurence_date = new utils_data.FrequencyTranslator().AddDate(Habit_, dt);
            }

            //return Habit_Data_;
        }
Ejemplo n.º 2
0
        public List <Habit_Data> habit_data_for_habit(Recurring item, DateTime?occurence_date = null)
        {
            string            sql    = "select * from habit_data where habit_data.job_id=" + Convert.ToString(item.ID);
            List <Habit_Data> output = _database.QueryAsync <Habit_Data>(sql).Result.ToList();

            output = output.Where(habit => (habit.date_run >= occurence_date)).ToList();
            return(output);
        }
Ejemplo n.º 3
0
        public void delete_habits_data(Recurring item, DateTime?occurence_date = null)
        {
            List <Habit_Data> habit_datas = habit_data_for_habit(item, occurence_date);

            foreach (Habit_Data habit_data_ in habit_datas)
            {
                DeleteItemAsync(habit_data_);
            }
        }
Ejemplo n.º 4
0
        async void OnButtonClicked(object sender, EventArgs e)
        {
            Recurring Habit_ = data_entry.GetHabit();
            int       job_id = await App.Database.SaveItemAsync(Habit_);

            data_entry.save_Habit_Data(Habit_);
            // habit_data_.Job_ID = job_id;

            this.refresh();
        }
Ejemplo n.º 5
0
 private void db_view_Clicked(object s, SelectedItemChangedEventArgs e)
 {
     try
     {
         Selected_ = (Recurring)e.SelectedItem;
     }
     catch (Exception)
     {
         //pass;
     }
 }
Ejemplo n.º 6
0
        public Task <int> SaveItemAsync(Recurring item, bool after_today = false)
        {
            if (item.ID != 0)
            {
                update_habit_data_for_habit(item, after_today);

                return(_database.UpdateAsync(item));
            }

            else
            {
                return(_database.InsertAsync(item));
            }
        }
Ejemplo n.º 7
0
        public void update_habit_data_for_habit(Recurring item, bool after_today = false)
        {
            DateTime?occurence_date;

            if (after_today)
            {
                occurence_date = DateTime.Today;
            }
            else
            {
                occurence_date = null;
            }
            delete_habits_data(item, occurence_date);

            //todo add option to resolve occurence_date
            save_habit_data(item, occurence_date);
        }
Ejemplo n.º 8
0
 public Task <int> DeleteHabitAsync(Recurring habit_inst)
 {
     return(_database.DeleteAsync(habit_inst));
 }
Ejemplo n.º 9
0
 public Task <int> DeleteItemAsync(Recurring item)
 {
     return(_database.DeleteAsync(item));
 }
Ejemplo n.º 10
0
 public Task <int> SavePersonAsync(Recurring habit)
 {
     return(_database.InsertAsync(habit));
 }