/// <summary> /// Saves the alarm details and adds the alarm to the database and alarm list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveBtn_Click(object sender, EventArgs e) { List <int> days = new List <int>(); //get days for alarm if (FindViewById <ToggleButton>(Resource.Id.cBoxSun).Checked) { days.Add(1); } if (FindViewById <ToggleButton>(Resource.Id.cBoxMon).Checked) { days.Add(2); } if (FindViewById <ToggleButton>(Resource.Id.cBoxTue).Checked) { days.Add(3); } if (FindViewById <ToggleButton>(Resource.Id.cBoxWed).Checked) { days.Add(4); } if (FindViewById <ToggleButton>(Resource.Id.cBoxThu).Checked) { days.Add(5); } if (FindViewById <ToggleButton>(Resource.Id.cBoxFri).Checked) { days.Add(6); } if (FindViewById <ToggleButton>(Resource.Id.cBoxSat).Checked) { days.Add(7); } if (days.Count == 0) { days.Add(0); } //make sure the alarm time has been set if (alarmTime.Text == "") { showMsg("You must set an alarm time!"); } else { //call the web service to add the new alarm if (NetworkInterface.GetIsNetworkAvailable()) { Service1 client = new Service1(); //get the days int[] daysSelected = days.ToArray(); //get the reminder time string reminderTime = alarmReminderSpinner.SelectedItem.ToString(); //get the alarm sound string alarmSound = null; if (uriToRingTone != null) { alarmSound = uriToRingTone.ToString(); } //add the new alarm client.AddNewAlarmAsync(username, alarmName.Text, timeOfAlarm.ToString(), "y", int.Parse(reminderTime.Substring(0, reminderTime.Length - 4)), alarmSound, daysSelected); client.AddNewAlarmCompleted += (object sender1, AddNewAlarmCompletedEventArgs e1) => { //make a new alarm object Alarm alarm = new Alarm { AlarmID = e1.Result, AlarmName = alarmName.Text, AlarmTime = timeOfAlarm, AlarmActive = true, AlarmReminder = int.Parse(alarmReminderSpinner.SelectedItem.ToString().Substring(0, reminderTime.Length - 4)), AlarmDays = days, AlarmSound = alarmSound }; //pass the intent the alarm object via JSON Intent intent = new Intent(); intent.PutExtra("NewAlarm", JsonConvert.SerializeObject(alarm)); SetResult(Result.Ok, intent); Finish(); }; } } }