private string DeactivateNotificationsWithNoChecklists(NotificationsEventTypesDto oNotification) { return oNotification.SelectedChecklists.Count != 0 ? null : "T"; }
public bool SaveNotification(NotificationsEventTypesDto oNotification, int updatedByUserID) { NotificationsEventType oNewEmailTemplate = new NotificationsEventType(); if (oNotification.EventTypeID == 0) { oNewEmailTemplate = new NotificationsEventType { Name = "Checklist – " + oNotification.EmailSubject, Deactivated = DeactivateNotificationsWithNoChecklists(oNotification), Metric_DateTimeCreated = DateTime.Now, ProductID = Convert.ToInt32(NetchemiaFoundations.Configuration.Products.RECORDS), EmailSubject = oNotification.EmailSubject, EmailBody = oNotification.EmailBody, UpdatedDateTime = DateTime.Now, DeactivatedByUserID = null, UpdatedByUserID = updatedByUserID, DeactivatedDateTime = null, IsSystemNotification = false }; _notificationEventTypes.Add(oNewEmailTemplate); } else { var oModifyNotification = _notificationEventTypes.FindById(oNotification.EventTypeID); // Issue #12710 - GTS - Edit Custom Checklist Email Title and also make sure to not change any predefind items only for new checklists and cusmizations if (!oModifyNotification.IsSystemNotification) { oModifyNotification.Deactivated = DeactivateNotificationsWithNoChecklists(oNotification); oModifyNotification.Name = "Checklist - " + oNotification.EmailSubject; } oModifyNotification.EmailSubject = oNotification.EmailSubject; oModifyNotification.EmailBody = oNotification.EmailBody; oModifyNotification.UpdatedDateTime = DateTime.Now; oModifyNotification.UpdatedByUserID = updatedByUserID; } try { _notificationEventTypes.SaveChanges(); if (oNotification.EventTypeID == 0) oNotification.EventTypeID = oNewEmailTemplate.EventTypeID; _checklistService.UpdateChecklistsWithNotificationChanges(oNotification); return true; } catch { return false; } }
public bool DeleteEmailTemplateByID(int id, int deletedByUserID) { NotificationsEventType oDeleteNotification = _notificationEventTypes.FindById(id); oDeleteNotification.Deactivated = "T"; oDeleteNotification.DeactivatedByUserID = deletedByUserID; oDeleteNotification.DeactivatedDateTime = DateTime.Now; oDeleteNotification.Deleted = true; oDeleteNotification.DeletedByUserID = deletedByUserID; oDeleteNotification.DeletedDateTime = DateTime.Now; NotificationsEventTypesDto oNotification = new NotificationsEventTypesDto { EventTypeID = oDeleteNotification.EventTypeID, SelectedChecklists = new List<SelectedChecklistDto>() }; try { _checklistService.UpdateChecklistsWithNotificationChanges(oNotification); _notificationEventTypes.SaveChanges(); return true; } catch { return false; } }