Ejemplo n.º 1
0
 public void DeleteTask (Task task)
 {
     var doc = _db.GetExistingDocument (task.ID);
     if(doc != null) {
         doc.Delete();
     }
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
 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);
            }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
 public void DeleteTask (Task task)
 {
     //Step 5 - Create delete logic
 }
Ejemplo n.º 7
0
 public void SaveTask (Task item)
 {
     //Step 4 - Create save logic
 }