private reminder AdjustTimeZone(reminder reminder) { if (reminder.reminderDate.Kind == DateTimeKind.Unspecified || reminder.reminderDate.Kind == DateTimeKind.Utc) { reminder.reminderDate = TimeZoneInfo.ConvertTime(reminder.reminderDate, TimeZoneInfo.Utc, TimeZoneInfo.Local); } return(reminder); }
public List <reminder> getTodayReminders() { string query = "SELECT * from Reminders WHERE reminder_date = Date() and dismissed = 0;"; List <reminder> reminders = new List <reminder>(); using (OleDbConnection connection = new OleDbConnection(this.connString)) { connection.Open(); OleDbDataReader reader = null; OleDbCommand command = new OleDbCommand(query, connection); reader = command.ExecuteReader(); while (reader.Read()) { int reminderId = Int32.Parse(reader[0].ToString()); DateTime reminderDate = Convert.ToDateTime(reader[1].ToString()); string reminderMessage = reader[2].ToString(); int appointmentId = Int32.Parse(reader[3].ToString()); int dismissed = Int32.Parse(reader[4].ToString()); reminder rem = new reminder(reminderId, reminderDate, reminderMessage, appointmentId, dismissed); reminders.Add(rem); } connection.Close(); reader.Close(); return(reminders); } }
private Panel addRemPanel(reminder r, int startPosition, int endPosition) { Panel p = new Panel(); p.Location = new Point(startPosition, endPosition); p.Width = 230; p.Height = 23; p.BackColor = Color.Transparent; Label desc = new Label(); desc.Location = new Point(10, 0); desc.Width = 167; desc.Height = 23; desc.Text = r.ReminderMessage; p.Controls.Add(desc); Label date = new Label(); date.Text = r.ReminderDate.ToShortDateString(); date.Width = 65; date.Height = 32; date.Location = new Point(167, 0); p.Controls.Add(date); return(p); }
public void Update(reminder reminder, int id) { Validate(reminder); FindOne(id); reminder.reminderDate = CommonMethods.ConvertToUtc(reminder.reminderDate); _reminderRepository.Update(reminder, id); }
public reminder getReminder(int issueId, int userId) { using (var dbContext = new Service_Requests_Data_GOVEntities()) { reminder rem = dbContext.reminders.SingleOrDefault(r => r.reminder_issue_id == issueId && r.reminder_user_id == userId); return(rem); } }
public void Update(reminder reminder, int id) { var reminderToUpdate = FindOne(id); if (reminderToUpdate == null) { return; } reminderToUpdate = reminder; _db.SaveChanges(); }
private void addRrem_button_Click(object sender, EventArgs e) { DateTime remDate = reminder_datetime.Value; string message = remMessage_text.Text == "" ? a.AppointmentDesc : remMessage_text.Text; reminder rem = new reminder(remDate, message, a.AppointmentId, 0); dbConn.saveReminder(rem); remMessage_text.Text = ""; reminder_datetime.Value = DateTime.Now; this.loadReminders(); }
public bool AddReminder([FromBody] reminder reminder) { try { this.repository.AddEntity(reminder); return(true); } catch { return(false); } }
public void Add(reminder reminder) { var reminderId = 0; if (_db.reminders.Count() > 0) { reminderId = _db.reminders.Max(r => r.reminderId); } reminder.reminderId = reminderId + 1; _db.reminders.Add(reminder); _db.SaveChanges(); }
public void updateReminder(int issueId, int userId, DateTime date, Boolean status) { using (var dbContext = new Service_Requests_Data_GOVEntities()) { reminder rem = dbContext.reminders.SingleOrDefault(r => r.reminder_issue_id == issueId && r.reminder_user_id == userId); if (rem != null) { rem.remider_date = date; rem.reminder_enabled = status; dbContext.SaveChanges(); } } }
private ReminderAggregate ConvertToAggregate(reminder reminder, AppointmentAggregate appointmentAggregate) { return(new ReminderAggregate() { AppointmentId = appointmentAggregate.Id, CustomerName = appointmentAggregate.CustomerName, Location = appointmentAggregate.Location, ReminderId = reminder.reminderId, ReminderDate = reminder.reminderDate, StartTime = appointmentAggregate.Start, EndTime = appointmentAggregate.End }); }
public Boolean reminderEnabled(int issueId, int userId) { using (var dbContext = new Service_Requests_Data_GOVEntities()) { reminder rem = dbContext.reminders.SingleOrDefault(r => r.reminder_issue_id == issueId && r.reminder_user_id == userId); if (rem != null && rem.reminder_enabled == true) { return(true); } else { return(false); } } }
/*public string getCommentsByAppointmentIdAsString(int appointmentId) * { * string comment = ""; * * string query = "SELECT comment FROM Comments where appointment_id = " + appointmentId + ";"; * using (OleDbConnection connection = new OleDbConnection(this.connString)) * { * connection.Open(); * OleDbDataReader reader = null; * OleDbCommand command = new OleDbCommand(query, connection); * reader = command.ExecuteReader(); * while (reader.Read()) * { * string com = reader[0].ToString(); * comment += com + " "; * } * connection.Close(); * reader.Close(); * return comment; * } * }*/ public void saveReminder(reminder rem) { string date = rem.ReminderDate.ToShortDateString(); string query = "INSERT INTO Reminders (reminder_date, reminder_message, appointment_id) VALUES ('" + date + "' , '" + rem.ReminderMessage + "', " + rem.AppointmentId + ");"; using (OleDbConnection connection = new OleDbConnection(this.connString)) { connection.Open(); OleDbDataReader reader = null; OleDbCommand command = new OleDbCommand(query, connection); reader = command.ExecuteReader(); connection.Close(); reader.Close(); } }
public int setMakhoiphuc(int user_id, string makhoiphuc) { var ketqua = db.reminders.Count(x => x.user_id == user_id); if (ketqua > 0) { return(0); } reminder reminder = new reminder(); reminder.user_id = user_id; reminder.code = makhoiphuc; reminder.completed_at = null; db.reminders.Add(reminder); return(db.SaveChanges()); }
public void Add(DateTime reminderDateTime, int appointmentId) { var incrementTypeId = incrementService.FindDefaultIncrement()?.incrementTypeId; reminderDateTime = CommonMethods.ConvertToUtc(reminderDateTime); var reminder = new reminder() { appointmentId = appointmentId, createdBy = _authRepository.Username, createdDate = CommonMethods.ConvertToUtc(DateTime.Now), reminderDate = reminderDateTime, snoozeIncrement = 5, snoozeIncrementTypeId = incrementTypeId.HasValue ? incrementTypeId.Value : 1 }; Validate(reminder); _reminderRepository.Add(reminder); }
private void Validate(reminder reminder) { if (reminder.reminderDate == null || reminder.reminderDate < DateTime.Now) { throw new InvalidInputException("Reminder date must be in the future"); } if (reminder.snoozeIncrement <= 0) { throw new InvalidInputException("Snooze increment value must be greater than 0"); } if (String.IsNullOrWhiteSpace(reminder.remindercol)) { reminder.remindercol = "Reminder"; } //Throws not found exception if not found incrementService.FindOne(reminder.snoozeIncrementTypeId); }
//Validation will take place in the other Add method's Validate method //And in IncrementService validate public void Add(ReminderAggregate reminderAggregate) { var reminder = new reminder() { reminderDate = reminderAggregate.ReminderDate, remindercol = reminderAggregate.ReminderCol, createdBy = _authRepository.Username }; var incrementType = new incrementtype() { incrementTypeDescription = reminderAggregate.IncrementDescription }; var incrementId = incrementService.Add(incrementType); reminder.snoozeIncrementTypeId = incrementId; Add(reminder); }
public void saveReminder(int issueId, int userId, DateTime date, bool status) { using (var dbContext = new Service_Requests_Data_GOVEntities()) { reminder re = dbContext.reminders.SingleOrDefault(r => r.reminder_issue_id == issueId && r.reminder_user_id == userId); if (re == null) { reminder remind = new reminder(); remind.reminder_issue_id = issueId; remind.reminder_user_id = userId; remind.remider_date = date; remind.reminder_enabled = status; dbContext.reminders.Add(remind); dbContext.SaveChanges(); } else { updateReminder(issueId, userId, date, status); } } }
public List <reminder> getRemindersForAppointment(int appointmentId) { string query = "SELECT * FROM Reminders where appointment_id = " + appointmentId + " AND dismissed = 0 ORDER BY reminder_date ASC;"; List <reminder> reminders = new List <reminder>(); using (OleDbConnection connection = new OleDbConnection(this.connString)) { connection.Open(); OleDbCommand command = new OleDbCommand(query, connection); OleDbDataReader reader = command.ExecuteReader(); while (reader.Read()) { DateTime remDate = Convert.ToDateTime(reader[1].ToString()); string message = reader[2].ToString(); int dissmised = Int32.Parse(reader[4].ToString()); reminder rem = new reminder(remDate, message, appointmentId, dissmised); reminders.Add(rem); } connection.Close(); reader.Close(); } return(reminders); }
private string replacePatterns(string input, reminder reminder) { string output = input; Regex r = new Regex(@"\[(.+?)\]", RegexOptions.IgnoreCase); Match m = r.Match(input); while (m.Success) { try { string pat = m.Groups[1].Value; string newVal = $"[{pat}]"; var arr = pat.Split('.'); if (arr[0] == "reminder") { newVal = reminder.GetType().GetProperty(arr[1]).GetValue(reminder, null).ToString(); } output = output.Replace($"[{pat}]", newVal); } catch { } m = m.NextMatch(); } return(output); }
public static IObservable<task> SetReminder(string id_task, reminder reminder) { return client.get<task>("tasks/set_reminder", new p() { { "id_task", id_task }, { "reminder", ((int)reminder).ToString() } }); }
public void Add(reminder reminder) { Validate(reminder); _reminderRepository.Add(reminder); }
private void save_button_Click(object sender, EventArgs e) { string appointmentDesc = description_text.Text.Replace("'", ""); string date = datePicker.Text; string time = TimePicker.Text; DateTime datetime = Convert.ToDateTime(date + " " + time); int appointmentTypeId = dbConn.getAppointmentTypeId(types_combo.SelectedItem.ToString()); string person1Id = id1_text.Text.Replace("'", ""); string person1Name = name1_text.Text.Replace("'", ""); string person1Surname = surname1_text.Text.Replace("'", ""); string person1Tel = tel1_text.Text.Replace("'", ""); string person2Id = id2_text.Text.Replace("'", ""); string person2Name = name2_text.Text.Replace("'", ""); string person2Surname = surname2_text.Text.Replace("'", ""); string person2Tel = tel2_text.Text.Replace("'", ""); DateTime appointmentCreated = DateTime.Now; string intermediary = intermediary_text.Text.Replace("'", ""); int done = 0; if (description_text.Text != "" && id1_text.Text != "" && name1_text.Text != "" && surname1_text.Text != "" && tel1_text.Text != "") { if (!dbConn.appointmentTitleExists(appointmentDesc)) { //Saving Appointment appointment app = new appointment(appointmentDesc, datetime, appointmentTypeId, person1Id, person1Name, person1Surname, person1Tel, appointmentCreated, intermediary, person2Id, person2Name, person2Surname, person2Tel, done, this.followup, this.followUpParentId); dbConn.SaveAppointment(app); int appointmentId = dbConn.getLastAppointmentId(); //Saving Comment if (parentApp == null) { string commentText = comment_text.Text.Replace("'", ""); if (commentText != "") { dbConn.saveComment(commentText, 1); } } else { //For Parent string commentDescription = "Follow Up Appoitnment Created"; dbConn.saveComment(commentDescription, 2, parentApp.AppointmentId); ea.addComment(commentDescription, DateTime.Now); //For self appointment string commentText = comment_text.Text.Replace("'", ""); if (commentText != "") { dbConn.saveComment(commentText, 1); } //Load All Follow Ups ea.loadFollowUps(); } //Saving Reminder string reminderMessage = remMessage_text.Text.Replace("'", ""); if (addReminder_check.Checked) { reminder rem = new reminder(Convert.ToDateTime(reminder_datetime.Text), reminderMessage, appointmentId, 0); dbConn.saveReminder(rem); } //Resetting form saved_label.Visible = true; hide_success_label.Interval = 3000; hide_success_label.Tick += hide_success_label_Tick; hide_success_label.Start(); description_text.Text = ""; id1_text.Text = ""; name1_text.Text = ""; surname1_text.Text = ""; tel1_text.Text = ""; id2_text.Text = ""; name2_text.Text = ""; surname2_text.Text = ""; tel2_text.Text = ""; intermediary_text.Text = ""; id2_text.Enabled = false; name2_text.Enabled = false; surname2_text.Enabled = false; tel2_text.Enabled = false; addPerson_check.Checked = false; comment_text.Text = ""; remMessage_text.Text = ""; addReminder_check.Checked = false; } else { error_label.Text = "Appointment Title already Exist!"; error_label.Visible = true; hide_error_label.Interval = 3000; hide_error_label.Tick += hide_error_label_Tick; hide_error_label.Start(); } } else // necessary fields are empty { if (description_text.Text == "") { required_desc.Visible = true; } if (id1_text.Text == "") { required_id.Visible = true; } if (name1_text.Text == "") { required_name.Visible = true; } if (surname1_text.Text == "") { required_surname.Visible = true; } if (tel1_text.Text == "") { required_tel.Visible = true; } error_label.Text = "Please Fill all Fields"; error_label.Visible = true; hide_error_label.Interval = 3000; hide_error_label.Tick += hide_error_label_Tick; hide_error_label.Start(); } }