public ItemEditPage (Appointment existingAppointment)
		{
			//Just a test
			existingAppointment = new Appointment (new Employee ("Johan", "Bakker", 0291, 06222222, "*****@*****.**", "medewerker"),
				new List<Collector> {new Collector ()},
				new List<Visitor> {new Visitor ("Henk", "DeBezoeker", "*****@*****.**", 06221122, "Sony", "klant")},
				"Apeldoorn",
				new DateTime (2016, 11, 11, 10, 15, 30));
			
			existingAppointment.Comment = "Het is prachtig weer vandaag.";

			InitializeComponent ();

			BindingContext = new ItemEditViewModel (existingAppointment);

			if (existingAppointment != null) {
				Title = "Bestaande afspraak";
			}
		}
		public void InsertAppointmentObject(Appointment appointmentObject){
			
			if (appointmentObject.EmployeeObject != null)
			{
				InsertEmployee(appointmentObject.EmployeeObject);
			}

			if (appointmentObject.VisitorList != null)
			{
				foreach (Visitor v in appointmentObject.VisitorList)
				{
					InsertVisitor(v);
				}
			}
			if (IsQueryPossible) {
				_connection.Transaction (() => _connection.Insert (appointmentObject));
			}

		}
		public void DeleteAppointmentObject(Appointment appointmentObject){
			if (IsQueryPossible) {
				_connection.Transaction (() => _connection.Delete (appointmentObject));
			}
		}
		public void UpdateAppointmentObject(Appointment appointmentObject){
			if (IsQueryPossible) {
				_connection.Transaction (() => _connection.InsertOrReplace (appointmentObject));
			}
		}
		/*
		public string LocationAddress {
			get {
				return _passwordObject.LocationAddress;
			}
			set {
				if (_passwordObject.LocationAddress != value) {
					_passwordObject.LocationAddress = value;
					RaisePropertyChanged ();
				}
			}
		}

		public string LocationZipAndCity {
			get {
				return _passwordObject.LocationZipAndCity;
			}
			set {
				if (_passwordObject.LocationZipAndCity != value) {
					_passwordObject.LocationZipAndCity = value;
					RaisePropertyChanged ();
				}
			}
		}

		public bool IsActive {
			get {
				return _passwordObject.IsActive;
			}
			set {
				if (_passwordObject.IsActive != value) {
					_passwordObject.IsActive = value;
					RaisePropertyChanged ();
				}
			}
		}

		public double ImportanceLevel {
			get {
				return _passwordObject.ImportanceLevel;
			}
			set {
				if (_passwordObject.ImportanceLevel != value) {
					_passwordObject.ImportanceLevel = value;
					RaisePropertyChanged ();
				}
			}
		}

		public DateTime AccountSince {
			get {
				return _passwordObject.AccountSince;
			}
			set {
				if (_passwordObject.AccountSince != value) {
					_passwordObject.AccountSince = value;
					RaisePropertyChanged ();
				}
			}
		}

		public string PathToImage1 {
			get {
				return _passwordObject.PathToImage1;
			}
			set {
				if (_passwordObject.PathToImage1 != value) {
					_passwordObject.PathToImage1 = value;
					RaisePropertyChanged ();
				}
			}
		}

		public string PathToImage2 {
			get {
				return _passwordObject.PathToImage2;
			}
			set {
				if (_passwordObject.PathToImage2 != value) {
					_passwordObject.PathToImage2 = value;
					RaisePropertyChanged ();
				}
			}
		}

		public string PathToImage3 {
			get {
				return _passwordObject.PathToImage3;
			}
			set {
				if (_passwordObject.PathToImage3 != value) {
					_passwordObject.PathToImage3 = value;
					RaisePropertyChanged ();
				}
			}
		}


		public string Category {
			get {
				return _passwordObject.Category;
			}
			set {
				if (_passwordObject.Category != value) {
					_passwordObject.Category = value;
					RaisePropertyChanged ();
				}
			}
		}

		public List<string> CategoriesToChoose{
			get {
				return new List<string> { "Privé", "Zakelijk" };
			}
		}
		*/
		public ItemEditViewModel (Appointment existingAppointmentObject)
		{
			
			if (existingAppointmentObject != null) {
				_appointmentObject = existingAppointmentObject;

				_isNewAppointmentObject = false;
			} else {
				_appointmentObject = new Appointment ();
				_isNewAppointmentObject = true;
			}
		}
		/*
		void HandleSearchTextChanged (string searchText)
		{
			Debug.WriteLine ("Searched for: " + searchText);

			if (!string.IsNullOrEmpty (searchText)) {

				var searchResults = _appointmentsToShow.Where (t => t.Name.ToLower ().Contains (searchText.ToLower ())).ToList (); 
					//|| t.Password.ToLower ().Contains (searchText.ToLower ())).ToList ();

				//before updating list, first check if list is changed
				var listIsNotChanged = searchResults.SequenceEqual(appointments.ToList ());

				if(!listIsNotChanged){
					
					PasswordItems.Clear();
					searchResults.ForEach (t => PasswordItems.Add (t));
				}
			} 
			else {
				//search bar cancel button clicked - so refresh list
				PasswordItems.Clear();
				_passwordItemsToShow = DatabaseHelper.Instance.GetPasswordObjects ();
			}
		}
		*/
		async void HandleItemSelected(Appointment selectedAppointment)
		{
			await DependencyService.Get<NavigationService> ().GoToPage(new ItemEditPage(selectedAppointment), true);
		}