private static void Ntofication() { Notification NewNotification = new Notification(); NewNotification.EntityId = ""; NewNotification.MvcUrl.Action = "Edit"; NewNotification.MvcUrl.Controller = "PurchaseOrders"; NewNotification.Description = "New Notification"; NewNotification.NotificationType = NotificationType.NEW_PURCHASE_ORDER; NewNotification.WarningLevel = WarningLevelType.NEUTRAL; NewNotification.ViewAdminUserRolesRequired.Add(PurchaseOrderRoles.VIEW); NewNotification.ViewAdminUserRolesRequired.Add(PurchaseOrderRoles.EDIT); NewNotification.ActionList.Insert(0, new NotificationAction("Edit", "glyphicon glyphicon-pencil", "Edit", "PurchaseOrders")); DashboardNotificationDAO.Save(NewNotification); }
/// <summary> /// Create a new notification customized for purchase orders. /// </summary> /// <param name="entityId"></param> /// <param name="description"></param> /// <returns></returns> private static Notification GenerateNewNotification(string entityId, string description) { Notification NewNotification = new Notification(); NewNotification.EntityId = entityId; NewNotification.MvcUrl.Action = "Edit"; NewNotification.MvcUrl.Controller = "PurchaseOrders"; NewNotification.Description = description; NewNotification.NotificationType = NotificationType.NEW_PURCHASE_ORDER; NewNotification.WarningLevel = WarningLevelType.NEUTRAL; NewNotification.ViewAdminUserRolesRequired.Add(PurchaseOrderRoles.VIEW); NewNotification.ViewAdminUserRolesRequired.Add(PurchaseOrderRoles.EDIT); NewNotification.ActionList.Insert(0, new NotificationAction("Edit", "glyphicon glyphicon-pencil", "Edit", "PurchaseOrders")); return NewNotification; }
/// <summary> /// Generate a new notification for a product stock level warning /// </summary> /// <param name="entityId"></param> /// <param name="stockLevel"></param> /// <returns></returns> private static Notification GenerateNewNotification(string name, string entityId, int stockLevel, List<CheckoutPropertySettingKey> checkoutPropSettingKeys = null) { Notification NewNotification = new Notification(); NewNotification.EntityId = entityId; NewNotification.MvcUrl.Action = "Edit"; NewNotification.MvcUrl.Controller = "Product"; NewNotification.NotificationType = NotificationType.STOCK_LEVEL; NewNotification.WarningLevel = WarningLevelType.DANGER; NewNotification.ViewAdminUserRolesRequired.Add(ProductRoles.VIEW); NewNotification.ViewAdminUserRolesRequired.Add(ProductRoles.EDIT); NewNotification.ActionList.Insert(0, new NotificationAction("Edit", "glyphicon glyphicon-pencil", "Edit", "Product")); if (checkoutPropSettingKeys != null && checkoutPropSettingKeys.Count > 0) { NewNotification.Description = String.Format("The following product \"{0}\" has a stock level of \"{1}\" with these checkout settings:<br/>", name, stockLevel); NewNotification.Description += "<ul>"; foreach (var CheckPropKey in checkoutPropSettingKeys) { NewNotification.Description += String.Format("<li>{0}: {1}</li>", CheckPropKey.Key, CheckPropKey.Value); } NewNotification.Description += "</ul>"; } else { NewNotification.Description = String.Format("The following product \"{0}\" has a stock level of \"{1}\".", name, stockLevel); } return NewNotification; }
/// <summary> /// Add a new dashboard notification. /// </summary> /// <param name="notification">The notification to add.</param> /// <returns>bool</returns> public static bool Save(Notification notification) { return Execute.Save<Notification>(COLLECTION_NAME, notification); }