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_; }
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); }
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_); } }
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(); }
private void db_view_Clicked(object s, SelectedItemChangedEventArgs e) { try { Selected_ = (Recurring)e.SelectedItem; } catch (Exception) { //pass; } }
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)); } }
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); }
public Task <int> DeleteHabitAsync(Recurring habit_inst) { return(_database.DeleteAsync(habit_inst)); }
public Task <int> DeleteItemAsync(Recurring item) { return(_database.DeleteAsync(item)); }
public Task <int> SavePersonAsync(Recurring habit) { return(_database.InsertAsync(habit)); }