private void ClearAlert(int alertNotificationId) { RockContext rockContext = new RockContext(); AlertNotificationService alertNotificationService = new AlertNotificationService(rockContext); AlertMessageService alertMessageService = new AlertMessageService(rockContext); var alert = alertNotificationService .Get(alertNotificationId); alert.IsActive = false; rockContext.SaveChanges(); }
protected void AllClear_Click(object sender, CommandEventArgs e) { if (e.CommandName == "AllClear_Click") { int index; bool bIsConverted = int.TryParse(e.CommandArgument.ToString(), out index); RockContext rockContext = new RockContext(); AlertNotificationService alertNotificationService = new AlertNotificationService(rockContext); AlertMessageService alertMessageService = new AlertMessageService(rockContext); var alert = alertNotificationService .Get(index); alert.IsActive = false; rockContext.SaveChanges(); BindRepeater(); } }
protected void mdSendUpdate_SendClick(object sender, EventArgs e) { int alertID = hfAlertID.Value.AsInteger(); if (tbAlertMessage.Text.IsNotNullOrWhiteSpace()) { RockContext rockContext = new RockContext(); AlertMessageService alertMessageService = new AlertMessageService(rockContext); AlertNotificationService alertNotificationService = new AlertNotificationService(rockContext); var alert = alertNotificationService .Get(alertID); var alertMessage = new AlertMessage { AlertNotification = alert, Message = tbAlertMessage.Text, }; alertMessageService.Add(alertMessage); rockContext.SaveChanges(); alertMessage.SendCommunication(GlobalAttributesCache.Value("DefaultSMSFromNumber").AsGuid()); } if (hfAllClear.Value.AsBoolean()) { ClearAlert(alertID); } mdSendUpdate.Hide(); BindRepeater(); }