Example #1
0
        public bool UpdateEntry(TaskDBData taskData)
        {
            ContentValues updateValues = GetContentValues(taskData);

            String where = GetWhereForTaskName(taskData.ID);
            db.Update(TaskTable, updateValues, where, null);
            return(true);
        }
Example #2
0
        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);
        }
Example #3
0
        public string InsertEntry(TaskDBData taskInfo)
        {
            ContentValues newValues = GetContentValues(taskInfo);

            try{
                long t = db.InsertOrThrow(TaskTable, null, newValues);
            }
            catch {
                return(null);
            }
            return(taskInfo.Name);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
            }
        }
Example #6
0
 public void UpdateTaskDBData(TaskDBData taskDBData)
 {
     DB.UpdateEntry(taskDBData);
 }
Example #7
0
 public bool DeleteEntry(TaskDBData taskData)
 {
     String where = GetWhereForTaskName(taskData.ID);
     db.Delete(TaskTable, where, null);
     return(true);
 }