private void _addProfessorButton_Click(object sender, EventArgs e) { errorHandlingFunctions newerror = new errorHandlingFunctions(); var profName = FindViewById <EditText>(Resource.Id.professorsNameAdd); var profPhone = FindViewById <EditText>(Resource.Id.professorsPhoneAdd); var profEmail = FindViewById <EditText>(Resource.Id.professorEmailAdd); var profId = FindViewById <EditText>(Resource.Id.professorId); int profIdInt; ProfessorRepository newRepository = new ProfessorRepository(); Instructor temp = new Instructor(); if (profId.Text.Trim() == "") { Toast.MakeText(this, "Please add an Id", ToastLength.Short).Show(); return; } else { profIdInt = int.Parse(profId.Text); } //temp.Id = int.Parse(FindViewById<EditText>(Resource.Id.professorId).Text); foreach (Instructor item in thisProfList) { if (profIdInt == item.Id) { Toast.MakeText(this, "Id already in use", ToastLength.Short).Show(); return; } } temp.Id = profIdInt; if (profName.Text.Trim() != "") { temp.Name = profName.Text; } else { Toast.MakeText(this, "Please add a valid name", ToastLength.Short).Show(); return; } if (profPhone.Text.Length == 10) { temp.PhoneNumber = profPhone.Text; } else { Toast.MakeText(this, "Please add a 10 digit number, including area code. No spaces or symbols", ToastLength.Short).Show(); return; } if (newerror.validEmail(profEmail.Text) == true) { temp.Email = profEmail.Text; } else { Toast.MakeText(this, "Please add a valid email", ToastLength.Short).Show(); return; } newRepository.AddProfessor(temp); _professorAdapter.AddToProfessors(temp); _professorAdapter.NotifyDataSetChanged(); thisProfList.Add(temp); thisProfString = new List <string>(); thisProfString = setProfSpinner(); var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, thisProfString); var spinnerProfDelete = FindViewById <Spinner>(Resource.Id.ProfessorDeleteSpinner); var profSpinnerEdit = FindViewById <Spinner>(Resource.Id.professorIdEdit); spinnerProfDelete.Adapter = adapter; profSpinnerEdit.Adapter = adapter; var ProfName = FindViewById <EditText>(Resource.Id.professorsNameAdd); var ProfPhoneNumber = FindViewById <EditText>(Resource.Id.professorsPhoneAdd); var ProfEmail = FindViewById <EditText>(Resource.Id.professorEmailAdd); var ProfId = FindViewById <EditText>(Resource.Id.professorId); ProfName.Text = ""; ProfPhoneNumber.Text = ""; ProfEmail.Text = ""; ProfId.Text = ""; }