public void DeleteTask (Task task) { var doc = _db.GetExistingDocument (task.ID); if(doc != null) { doc.Delete(); } }
private Task CreateNewListItem(string text) { var task = new Task() { Text = text, Checked = false, CreationDate = DateTime.UtcNow }; var taskManager = new TaskManager(); taskManager.SaveTask(task); return task; }
public void SaveTask (Task item) { if (item.ID == null) { Document doc = _db.CreateDocument (); doc.PutProperties (item.ToDictionary ()); item.ID = doc.Id; } else { Document doc = _db.GetDocument (item.ID); doc.Update (newRevision => { newRevision.SetUserProperties(item.ToDictionary()); return true; }); } }
public override void EditingEnded(UITextField textField) { if(textField.Text.Length == 0) { return; } var task = new Task() { Text = textField.Text, Checked = false, CreationDate = DateTime.UtcNow }; var taskManager = new TaskManager(); taskManager.SaveTask(task); }
public static Task FromDictionary(IDictionary<string, object> properties) { Task t = new Task(); try { t.ID = properties["_id"] as string; t.Text = properties["text"] as string; t.Checked = (bool)properties["checked"]; t.CreationDate = (DateTime)properties["created_at"]; } catch(KeyNotFoundException) { Log.E(TAG, "Invalid dictionary passed to FromDictionary"); return null; } catch(InvalidCastException) { Log.E(TAG, "Dictionary contains invalid value(s)"); return null; } return t; }
public void DeleteTask (Task task) { //Step 5 - Create delete logic }
public void SaveTask (Task item) { //Step 4 - Create save logic }