/// <summary> /// Sets the reminder. /// </summary> /// <param name="reminder">Reminder.</param> public void SetReminder(SubjectReminder reminder) { db.Write(() => { student = db.All <Student>().ToList()[0]; student.Reminders.ToList().Add(reminder); }); }
/// <summary> /// Removes the reminder. /// </summary> /// <param name="reminder">Reminder.</param> public void RemoveReminder(SubjectReminder reminder) { db.Write(() => { student = db.All <Student>().ToList()[0]; bool removed = student.Reminders.ToList().Remove(reminder); }); db.Refresh(); }
public bool GetReminderState(Subject sub, string dayOfWeek) { var modified = new Subject { Name = sub.Name, Time = new TimeProvider().ConvertLectureTimeToAlarmTime(sub.Time), Period = sub.Period, Semester = sub.Semester }; var reminder = new SubjectReminder { Subject = modified, DayOfWeek = dayOfWeek, Semester = sub.Semester }; return(db.GetReminderState(reminder)); }
public void RemoveReminder(Subject sub, string dayOfWeek) { var modified = new Subject { Name = sub.Name, Time = new TimeProvider().ConvertLectureTimeToAlarmTime(sub.Time), Period = sub.Period, Semester = sub.Semester }; var reminder = new SubjectReminder { Subject = modified, DayOfWeek = dayOfWeek, Semester = sub.Semester, OnOf = true }; db.RemoveReminder(reminder); helper.CancelNotification(reminder); }
public void SetReminder(Subject sub, string dayOfWeek) { var modified = new Subject { Name = sub.Name, Time = new TimeProvider().ConvertLectureTimeToAlarmTime(sub.Time), Period = sub.Period, Semester = sub.Semester }; var reminder = new SubjectReminder { Subject = modified, DayOfWeek = dayOfWeek, Semester = sub.Semester, OnOf = true }; db.SetReminder(reminder); helper.ScheduleNotification(reminder, db.GetMinutesToSendBeforeTime()); }
/// <summary> /// Gets the state of the reminder. /// </summary> /// <returns><c>true</c>, if reminder state was gotten, <c>false</c> otherwise.</returns> /// <param name="s">S.</param> public bool GetReminderState(SubjectReminder s) { var subject = s.Subject; student = db.All <Student>().ToList()[0]; var reminders = student.Reminders; var state = false; if (reminders == null) { return(state); } for (int i = 0; i < reminders.Count; i++) { var sub = reminders[i].Subject; if (sub.Name == subject.Name && sub.Period == subject.Period && sub.Time == subject.Time && s.Semester == reminders[i].Semester && s.DayOfWeek == reminders[i].DayOfWeek) { state = reminders[i].OnOf; } } return(state); }
public void CancelNotification(SubjectReminder s) { CrossNotifications.Current.Cancel(s.ReminderID); }
public void ScheduleNotification(SubjectReminder s, int seconds) { var Dayprovider = new DayProvider(); var dayconverter = new DayConverter(); var message = "Your Lecture is starting shortly!"; var message1 = "Your Practical is starting shortly!"; var message2 = "Your tutorial is starting shortly!"; var message3 = "The tutorial/practical you tutor is starting shortly!"; var time = s.Subject.Time.Split(':'); DateTime nextday = Dayprovider.GetNextWeekday(DateTime.Today, dayconverter.ConvertToDayOfWeek(s.DayOfWeek)); DateTime newnextday = new DateTime(nextday.Year, nextday.Month, nextday.Day, Convert.ToInt32(time[0]), Convert.ToInt32(time[1]), Convert.ToInt32(time[2])); newnextday.AddSeconds(-seconds); if (DateTime.Today.DayOfWeek.ToString().Split(',')[0] == s.DayOfWeek) { if (s.Subject.Name.Contains("TUTOR")) { //CrossLocalNotifications.Current.Show(s.Subject.Name, message3, s.ReminderID, newnextday); CrossNotifications.Current.Send(new Notification { Title = s.Subject.Name, Message = message3, Vibrate = true, When = newnextday.TimeOfDay, Sound = "definite", Date = newnextday }); } if (s.Subject.Name.Contains("PRACTICAL")) { //CrossLocalNotifications.Current.Show(s.Subject.Name, message1, s.ReminderID, newnextday); CrossNotifications.Current.Send(new Notification { Title = s.Subject.Name, Message = message1, Vibrate = true, When = newnextday.TimeOfDay, Sound = "definite", Date = newnextday }); } if (s.Subject.Name.Contains("TUTORIAL")) { //CrossLocalNotifications.Current.Show(s.Subject.Name, message2, s.ReminderID, newnextday); CrossNotifications.Current.Send(new Notification { Title = s.Subject.Name, Message = message2, Vibrate = true, When = newnextday.TimeOfDay, Sound = "definite", Date = newnextday }); } if (s.Subject.Name.Contains("LECTURE")) { //CrossLocalNotifications.Current.Show(s.Subject.Name, message, s.ReminderID, newnextday); CrossNotifications.Current.Send(new Notification { Title = s.Subject.Name, Message = message, Vibrate = true, When = newnextday.TimeOfDay, Sound = "definite", Date = newnextday }); } } else { if (s.Subject.Name.Contains("TUTOR")) { //CrossLocalNotifications.Current.Show(s.Subject.Name, message3, s.ReminderID, newnextday); CrossNotifications.Current.Send(new Notification { Title = s.Subject.Name, Message = message3, Vibrate = true, When = newnextday.TimeOfDay, Sound = "definite", Date = newnextday }); } if (s.Subject.Name.Contains("PRACTICAL")) { //CrossLocalNotifications.Current.Show(s.Subject.Name, message1, s.ReminderID, newnextday); CrossNotifications.Current.Send(new Notification { Title = s.Subject.Name, Message = message1, Vibrate = true, When = newnextday.TimeOfDay, Sound = "definite", Date = newnextday }); } if (s.Subject.Name.Contains("TUTORIAL")) { //CrossLocalNotifications.Current.Show(s.Subject.Name, message2, s.ReminderID, newnextday); CrossNotifications.Current.Send(new Notification { Title = s.Subject.Name, Message = message2, Vibrate = true, When = newnextday.TimeOfDay, Sound = "definite", Date = newnextday }); } if (s.Subject.Name.Contains("LECTURE")) { //CrossLocalNotifications.Current.Show(s.Subject.Name, message, s.ReminderID, newnextday); CrossNotifications.Current.Send(new Notification { Title = s.Subject.Name, Message = message, Vibrate = true, When = newnextday.TimeOfDay, Sound = "definite", Date = newnextday }); } } }