public bool UpdateEntry(TaskDBData taskData) { ContentValues updateValues = GetContentValues(taskData); String where = GetWhereForTaskName(taskData.ID); db.Update(TaskTable, updateValues, where, null); return(true); }
private ContentValues GetContentValues(TaskDBData taskInfo) { ContentValues newValues = new ContentValues(); newValues.Put(TaskTableTaskNameKeyName, taskInfo.Name); newValues.Put(TaskTableOverallAttemptsKeyName, taskInfo.OverallAttempts); newValues.Put(TaskTableRightAttemptsKeyName, taskInfo.RightAttempts); return(newValues); }
public string InsertEntry(TaskDBData taskInfo) { ContentValues newValues = GetContentValues(taskInfo); try{ long t = db.InsertOrThrow(TaskTable, null, newValues); } catch { return(null); } return(taskInfo.Name); }
public int AnsweredTasksForTheme(SubjectTheme theme) { int answeredCount = 0; foreach (var task in GetTasks(theme.Num)) { var taskName = CreateTaskName(task, theme); TaskDBData dbTask = DB.GetEntry(taskName); if (dbTask == null) { DB.InsertEntry(new TaskDBData() { Name = taskName, OverallAttempts = 0, RightAttempts = 0 }); continue; } if (dbTask.RightAttempts > 0) { answeredCount++; } } return(answeredCount); }
public TaskDBData GetEntry(string taskName) { String[] resultColumns = new string[] { TaskTableKeyId, TaskTableTaskNameKeyName, TaskTableOverallAttemptsKeyName, TaskTableRightAttemptsKeyName }; try { var cursor = db.Query(TaskTable, resultColumns, null, null, null, null, null); cursor.MoveToFirst(); do { var idNum = cursor.GetInt(cursor.GetColumnIndex(TaskTableKeyId)); var nameNum = cursor.GetString(cursor.GetColumnIndex(TaskTableTaskNameKeyName)); var overallNum = cursor.GetInt(cursor.GetColumnIndex(TaskTableOverallAttemptsKeyName)); var rightNum = cursor.GetInt(cursor.GetColumnIndex(TaskTableRightAttemptsKeyName)); if (nameNum == taskName) { var taskDBData = new TaskDBData() { ID = idNum, Name = nameNum, OverallAttempts = overallNum, RightAttempts = rightNum }; return(taskDBData); } } while(cursor.MoveToNext()); return(null); } catch (Exception ex) { return(null); } }
public void UpdateTaskDBData(TaskDBData taskDBData) { DB.UpdateEntry(taskDBData); }
public bool DeleteEntry(TaskDBData taskData) { String where = GetWhereForTaskName(taskData.ID); db.Delete(TaskTable, where, null); return(true); }