コード例 #1
0
		public int Save(Task t) {
			if (t.Id != 0) {
				conn.Update (t);
				return t.Id;
			} else {
				return conn.Insert (t);
			}
		}
コード例 #2
0
		protected override void OnCreate (Android.OS.Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			vm = new TaskViewModel ();

			int taskID = Intent.GetIntExtra("TaskId", 0);
			if (taskID > 0) {
				currentTask = vm.Get (taskID);
			} else {
				currentTask = new Task ();
			}


			SetContentView(Resource.Layout.TaskView);

			titleText = FindViewById<EditText>(Resource.Id.TitleText);
			doneCheckBox = FindViewById<CheckBox>(Resource.Id.DoneCheckBox);

			titleText.Text = currentTask.Title;
			doneCheckBox.Checked = currentTask.Done;

			saveButton = FindViewById<Button>(Resource.Id.SaveButton);

			saveButton.Click += (sender, e) => {
				currentTask.Title = titleText.Text;
				currentTask.Done = doneCheckBox.Checked;

				currentTask.Id = vm.Save (currentTask); // unnecessary

				Finish();
			};


			var cancelButton = FindViewById<Button> (Resource.Id.CancelButton);
			cancelButton.Click += (sender, e) => {
				Finish();
			};
		}
コード例 #3
0
		public int Delete(Task t) {
			lock (locker) {
				return conn.Delete<Task> (t.Id); //primary key, not object itself
			}
		}