public bool SendMessage(string message, NotificationMessageType messageType, TimeSpan msgLifespan) { var msg = new NotificationMessage { Body = message, Date = DateTime.Now }; bool success; BrokeredMessage bm = null; try { bm = new BrokeredMessage(msg) { TimeToLive = msgLifespan }; // used for filtering bm.Properties[MessagePropertyType] = messageType.ToString(); _topicClient.Send(bm); success = true; } catch (Exception) { success = false; // TODO: do something } finally { if (bm != null) // if was created successfully { bm.Dispose(); } } return(success); }
public static void ShowMessage(this Controller controller, NotificationMessageType messageType, string message, bool showAfterRedirect = false) { var messageTypeKey = messageType.ToString(); if (showAfterRedirect) { controller.TempData[messageTypeKey] = message; } else { controller.ViewData[messageTypeKey] = message; } }
public NoItemException( string instituteCode, int instituteUserId, int itemId, NotificationMessageType type) : base(string.Format("No Item present for instituteCode: {0}, instituteUserId: {1},", (object)instituteCode, (object)instituteUserId) + string.Format("itemId: {0}, Type: {1}", (object)itemId, (object)type.ToString())) { this.InstituteCode = instituteCode; this.InstituteUserId = instituteUserId; this.ItemId = itemId; this.Type = type; }