protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            string taskID = Intent.GetStringExtra("TaskID") ?? string.Empty;

            if (!string.IsNullOrEmpty(taskID))
            {
                var getResponse = await TodoManager.GetTodo(taskID);

                task = getResponse.Success.FirstOrDefault().Value;
            }

            // set our layout to be the home screen
            SetContentView(Resource.Layout.TaskDetails);
            nameTextEdit  = FindViewById <EditText>(Resource.Id.NameText);
            notesTextEdit = FindViewById <EditText>(Resource.Id.NotesText);
            saveButton    = FindViewById <Button>(Resource.Id.SaveButton);

            // find all our controls
            cancelDeleteButton = FindViewById <Button>(Resource.Id.CancelDeleteButton);

            // set the cancel delete based on whether or not it's an existing task
            cancelDeleteButton.Text = "Delete";

            nameTextEdit.Text  = task.Name;
            notesTextEdit.Text = task.Notes;

            // button clicks
            cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
            saveButton.Click         += (sender, e) => { Save(); };
        }
Example #2
0
		protected async override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

            RequestWindowFeature(WindowFeatures.ActionBar);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);
			
			int taskID = Intent.GetIntExtra("TaskID", 0);

			if(taskID > 0) 
				task = await TodoManager.GetTaskAsync(taskID);
			
			// set our layout to be the home screen
			SetContentView(Resource.Layout.TaskDetails);
			nameTextEdit = FindViewById<EditText>(Resource.Id.txtName);
			notesTextEdit = FindViewById<EditText>(Resource.Id.txtNotes);
			doneCheckbox = FindViewById<CheckBox>(Resource.Id.chkDone);
			
            if (nameTextEdit != null)
			    nameTextEdit.Text = task.Name;
            
            if (notesTextEdit != null)
			    notesTextEdit.Text = task.Notes;
            
            if (doneCheckbox != null)
			    doneCheckbox.Checked = task.Done;
		}
Example #3
0
        public void FantomChild()
        {
            var parent = new TodoData()
            {
                Id           = "1",
                Parent       = null,
                Attributes   = new Dictionary <string, string>(),
                EstimateTime = TimeSpan.FromSeconds(1),
                Name         = "TestTodo",
                TimeRecords  = new[]
                {
                    new TimeRecordData {
                        Start = new DateTime(2014, 02, 03, 11, 22, 33),
                        End   = new DateTime(2014, 02, 03, 11, 22, 34)
                    }
                },
                Completed = true
            };


            var manager = new TodoManager();

            manager.UpsertTodo(parent);
            var pt = manager.GetTodo(parent.Id);

            pt.AddChild();
            manager.UpsertTodoRange(TodoConvert.Convert(pt));
            Assert.Single(pt.Children);
        }
Example #4
0
        public void Start()
        {
            var data = new TodoData()
            {
                Id           = "1",
                Parent       = null,
                Attributes   = new Dictionary <string, string>(),
                EstimateTime = TimeSpan.FromSeconds(1),
                Name         = "TestTodo",
                TimeRecords  = new[]
                {
                    new TimeRecordData {
                        Start = new DateTime(2014, 02, 03, 11, 22, 33),
                        End   = new DateTime(2014, 02, 03, 11, 22, 34)
                    }
                },
                Completed = true
            };

            var manager = new TodoManager();
            var changes = manager.UpsertTodo(data);
            var m2      = new TodoManager();

            m2.ApplyChange(changes);
            var todo = m2.GetTodo(data.Id);

            todo.Start();
            var change = manager.UpsertTodo(TodoConvert.ConvertSingle(todo));
            var result = manager.TopTodo.First();

            Assert.Equal(new[] { "1" }, change.Upsert.Select(t => t.Id).OrderBy(id => id));

            Assert.Equal("1", result.Id);
            Assert.Equal(2, result.TimeRecords.Count());
        }
Example #5
0
        public void Add1ParentAnd1ChildAndCompleteChild()
        {
            // Arrange
            ITodoManager todoManager = new TodoManager();

            // Act
            ITodo parentTodo = new Todo()
            {
                Task = "Parent1",
            };

            todoManager.AddTodo(parentTodo);
            ITodo childTodo = new Todo()
            {
                Task = "Child1",
            };

            todoManager.AddTodo(childTodo, parentTodo);
            childTodo.IsCompleted = true;

            // Verify
            var expectedParentIsCompleted = true;
            var actualParentIsCompleted   = parentTodo.IsCompleted;

            Assert.AreEqual(expectedParentIsCompleted, actualParentIsCompleted);

            var expectedChildIsCompleted = true;
            var actualChildIsCompleted   = childTodo.IsCompleted;

            Assert.AreEqual(expectedChildIsCompleted, actualChildIsCompleted);
        }
Example #6
0
        public void DeleteSingleAndNoParent()
        {
            var data = new TodoData()
            {
                Id           = "1",
                Parent       = null,
                Attributes   = new Dictionary <string, string>(),
                EstimateTime = TimeSpan.FromSeconds(1),
                Name         = "TestTodo",
                TimeRecords  = new[]
                {
                    new TimeRecordData {
                        Start = new DateTime(2014, 02, 03, 11, 22, 33),
                        End   = new DateTime(2014, 02, 03, 11, 22, 34)
                    }
                },
                Completed = true
            };

            var manager = new TodoManager();

            manager.UpsertTodo(data);
            var change = manager.DeleteTodo(data.Id);

            Assert.Equal(new[] { "1" }, change.Delete.Select(t => t.Id).OrderBy(id => id));
            Assert.Empty(manager.TopTodo);
        }
Example #7
0
        public void Add1ParentAndRemoveUnaddedTodo()
        {
            // Arrange
            ITodoManager todoManager = new TodoManager();

            // Act
            ITodo parentTodo = new Todo()
            {
                Task = "Parent1",
            };

            todoManager.AddTodo(parentTodo);
            ITodo todoToRemove = new Todo()
            {
                Task = "Parent1",
            };

            todoManager.RemoveTodo(todoToRemove);

            // Verify
            var expectedCount = 1;
            var actualCount   = todoManager.GetTotalParentCount();

            Assert.AreEqual(expectedCount, actualCount);
        }
Example #8
0
        public void Add1Parent1Child1Grandchild()
        {
            // Arrange
            ITodoManager todoManager = new TodoManager();

            // Act
            ITodo parentTodo = new Todo()
            {
                Task = "Parent1",
            };

            todoManager.AddTodo(parentTodo);
            ITodo childTodo = new Todo()
            {
                Task = "Child1",
            };

            todoManager.AddTodo(childTodo, parentTodo);
            ITodo grandchildTodo = new Todo()
            {
                Task = "Grandchild1",
            };

            todoManager.AddTodo(grandchildTodo, childTodo);

            // Verify
            var expectedCount = 2;
            var actualCount   = todoManager.GetTotalTodoCount();

            Assert.AreEqual(expectedCount, actualCount);
        }
Example #9
0
        public void Add1ParentAnd1ChildAndRemoveParent()
        {
            // Arrange
            ITodoManager todoManager = new TodoManager();

            // Act
            ITodo parentTodo = new Todo()
            {
                Task = "Parent1",
            };

            todoManager.AddTodo(parentTodo);
            ITodo childTodo = new Todo()
            {
                Task = "Child1",
            };

            todoManager.AddTodo(childTodo, parentTodo);
            todoManager.RemoveTodo(parentTodo);

            // Verify
            var expectedCount = 0;
            var actualCount   = todoManager.GetTotalParentCount();

            Assert.AreEqual(expectedCount, actualCount);

            var expectedChildCount = 0;
            var actualChildCount   = todoManager.GetTotalChildCount();

            Assert.AreEqual(expectedChildCount, actualChildCount);
        }
Example #10
0
        public void TestWorkersAndEntries()
        {
            TodoManager mgr = new TodoManager(50, 10, 1, 5, 5000, 1);

            mgr.Start();

            Assert.AreEqual(0, mgr.NumEntries());
            Assert.AreEqual(0, mgr.NumWorkers());

            mgr.Add(new MyTodo());

            Assert.AreEqual(1, mgr.NumEntries());
            Assert.AreEqual(1, mgr.NumWorkers());

            // experiment with a total of 50 entries.
            for (int i = 0; i < 49; i++)
            {
                mgr.Add(new MyTodo());
            }

            Assert.AreEqual(50, MyTodo.LastIdGenerated());

            WaitTillComplete(4000);
            //Assert.AreEqual( 5, mgr.NumWorkers() );


            // test if all todo's were executed.
            Assert.AreEqual(0, mgr.NumEntries());

            TodoManager.ShutDown();
        }
Example #11
0
        public void Doit(TodoManager mgr)
        {
            StructValue req = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_ReqWithMessage, vf);

            req.Add(MyValueFactoryCuae._mf_code, code);
            req.Add(MyValueFactoryCuae._mf_msg, message);

            Message msg = new Message(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_CuaeClient_doit2, vf);

            msg.Add(MyValueFactoryCuae._mf_req, req);

            Mailbox mb    = svc.BeginCall(msg);
            Object  value = svc.EndCall(mb, MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_CuaeServer__result_doit2);

            if (value is Exception)
            {
                Exception e = (Exception)value;
                throw e;
            }

            StructValue resp = (StructValue)value;

            //		resp.CheckType( MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response );
            MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response.CheckIsAssignableFrom(resp.GetXType);
            Console.WriteLine("**** delayDoit2b: req {0} response {1}\n", code, resp);
            //			String m = (String) resp.Get( MyValueFactoryCuae._mf_msg );
        }
Example #12
0
        public async Task <IActionResult> DeleteTodo(int id)
        {
            return(await AsyncMethods(async() => {
                var result = await TodoManager.Delete(id);

                return Ok(result);
            }));
        }
Example #13
0
        public async Task <IActionResult> AddTodo([FromBody] Todo todo)
        {
            return(await AsyncMethods(async() => {
                var result = await TodoManager.Create(todo);

                return Ok(result);
            }));
        }
Example #14
0
        public async Task <IActionResult> GetTodos([FromQuery] TodoFilter filters)
        {
            return(await AsyncMethods(async() => {
                var result = await TodoManager.GetFiltered(filters.ToDictionary());

                return Ok(result);
            }));
        }
Example #15
0
 public async void DeleteTask()
 {
     if (currentTask.ID >= 0)
     {
         await TodoManager.DeleteTaskAsync(currentTask);
     }
     NavigationController.PopViewController(true);
 }
        private async void HandleSave(object sender, RoutedEventArgs e)
        {
            var taskvm = (TaskViewModel)DataContext;
            var task   = taskvm.GetTask();
            await TodoManager.SaveTaskAsync(task);

            Frame.GoBack();
        }
        async void Save()
        {
            task.Name  = nameTextEdit.Text;
            task.Notes = notesTextEdit.Text;
            await TodoManager.SaveTodo(task);

            Finish();
        }
Example #18
0
		protected async void CancelDelete()
		{
			if(task.ID != 0) 
            {
				await TodoManager.DeleteTaskAsync(task);
			}
			
            Finish();
		}
Example #19
0
		protected async void Save()
		{
			task.Name = nameTextEdit.Text;
			task.Notes = notesTextEdit.Text;
			task.Done = doneCheckbox.Checked;
			await TodoManager.SaveTaskAsync(task);
			
            Finish();
		}
Example #20
0
        public async Task <IActionResult> UpdateTodo(int id, [FromBody] Todo todo)
        {
            return(await AsyncMethods(async() => {
                todo.Id = id;
                var result = await TodoManager.Update(todo);

                return Ok(result);
            }));
        }
Example #21
0
        public async void SaveTask()
        {
            context.Fetch();              // re-populates with updated values
            currentTask.Name  = taskDialog.Name;
            currentTask.Notes = taskDialog.Notes;
            currentTask.Done  = taskDialog.Done;
            await TodoManager.SaveTaskAsync(currentTask);

            NavigationController.PopViewController(true);
        }
        public async Task BeginUpdate()
        {
            IsUpdating = true;

            var entries = await TodoManager.GetTasksAsync();

            PopulateData(entries.ToList());

            IsUpdating = false;
        }
Example #23
0
 private void delayDoit2b(int code, string msg)
 {
     try
     {
         TodoManager.AddTodo(new ToDoObj1(svc, vf, code, msg));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Example #24
0
 private void delayDoit2a(int code)
 {
     try
     {
         TodoManager.AddTodo(new ToDoObj(svc, vf, code));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Example #25
0
 public App()
 {
     if (TodoManager.IsUserLoggedIn())
     {
         MainPage = new NavigationPage(new TodoListPage());
     }
     else
     {
         MainPage = new NavigationPage(new LoginPage());
     }
 }
        private async void HandleDelete(object sender, RoutedEventArgs e)
        {
            var taskvm = (TaskViewModel)DataContext;

            if (taskvm.ID >= 0)
            {
                await TodoManager.DeleteTaskAsync(taskvm.GetTask());
            }

            Frame.GoBack();
        }
Example #27
0
        public void TestShutDown()
        {
            TodoManager mgr = TodoManager.GetTodoManager();

            mgr.Add(new MyTodo());

            TodoManager.ShutDown();

            // adding after shutting down should cause exception
            mgr.Add(new MyTodo());
        }
Example #28
0
        public override void OnCreate()
        {
            // Initialize the database name.
            const string sqliteFilename = "TaskDB.db3";
            string       libraryPath    = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var          path           = Path.Combine(libraryPath, sqliteFilename);

            TodoManager.Initialize(path);

            base.OnCreate();
        }
Example #29
0
        protected async override void OnResume()
        {
            base.OnResume();

            tasks = await TodoManager.GetTasksAsync();

            // create our adapter
            taskList = new Adapters.TaskListAdapter(this, tasks);

            //Hook up our adapter to our ListView
            taskListView.Adapter = taskList;
        }
Example #30
0
        public TodoService(TodoManager todoManager, TodoItemRepository todoItemRepository)
        {
            this.TodoManager        = todoManager;
            this.TodoItemRepository = todoItemRepository;

            this.TodoManager.ChangedAsObservable
            .Throttle(TimeSpan.FromMilliseconds(10))
            .ObserveOnUIDispatcher()
            .Subscribe(x =>
            {
                this.TodoItemRepository.Save(x);
            });
        }