Exemplo n.º 1
0
        /// <summary>
        /// Display notification
        /// </summary>
        /// <param name="type">Notification type</param>
        /// <param name="message">Message</param>
        /// <param name="persistForTheNextRequest">A value indicating whether a message should be persisted for the next request</param>
        protected virtual void AddNotification(PageAlertType type, string message, bool persistForTheNextRequest)
        {
            string dataKey = $"ags.notifications.{type}";

            if (persistForTheNextRequest)
            {
                //1. Compare with null (first usage)
                //2. For some unknown reasons sometimes List<string> is converted to string[]. And it throws exceptions. That's why we reset it
                if (TempData[dataKey] == null || !(TempData[dataKey] is List <string>))
                {
                    TempData[dataKey] = new List <string>();
                }
                ((List <string>)TempData[dataKey]).Add(message);
            }
            else
            {
                //1. Compare with null (first usage)
                //2. For some unknown reasons sometimes List<string> is converted to string[]. And it throws exceptions. That's why we reset it
                if (ViewData[dataKey] == null || !(ViewData[dataKey] is List <string>))
                {
                    ViewData[dataKey] = new List <string>();
                }
                ((List <string>)ViewData[dataKey]).Add(message);
            }
        }
Exemplo n.º 2
0
        internal void AddPageAlerts(PageAlertType pageAlertType, string title, string description = "")
        {
            List <PageAlert> pageAlerts;

            if (ViewBag.PageAlerts == null)
            {
                pageAlerts = new List <PageAlert>();
            }
            else
            {
                pageAlerts = ViewBag.PageAlerts as List <PageAlert>;
            }

            pageAlerts.Add(new PageAlert(pageAlertType, title, description));
            ViewBag.PageAlerts = pageAlerts;
        }
Exemplo n.º 3
0
        internal void AddPageAlerts(PageAlertType pageAlertType, string description)
        {
            List <Message> messages;

            if (ViewBag.PageAlerts == null)
            {
                messages = new List <Message>();
            }
            else
            {
                messages = ViewBag.PageAlerts as List <Message>;
            }

            messages.Add(new Message {
                Type = pageAlertType.ToString().ToLower(), ShortDesc = description
            });
            ViewBag.PageAlerts = messages;
        }
Exemplo n.º 4
0
        protected void AddPageAlerts(PageAlertType pageAlertType, string description)
        {
            List <PageAlert> pageAlerts;

            if (TempData["PageAlerts"] == null)
            {
                pageAlerts = new List <PageAlert>();
            }
            else
            {
                pageAlerts = TempData["PageAlerts"] as List <PageAlert>;
            }

            pageAlerts.Add(new PageAlert {
                Type = pageAlertType.ToString().ToLower(), ShortDesc = description
            });
            TempData["PageAlerts"] = pageAlerts;
        }
Exemplo n.º 5
0
 public PageAlert(PageAlertType type, string title, string description)
 {
     Type        = type;
     Title       = title;
     Description = description;
 }