Exemplo n.º 1
0
        protected ActionResult RedirectWithRoute(string action, string message = null, bool error = true, object routeValues = null)
        {
            if (!message.IsNullOrEmpty())
            {
                ViewData.SetNotification(error ? UiNotification.Error(message) : UiNotification.Confirmation(message));
            }

            return(routeValues == null?RedirectToAction(action) : RedirectToAction(action, routeValues));
        }
Exemplo n.º 2
0
        protected ActionResult RedirectWithViewModel <TPostModel, TViewModel>(TPostModel postModel, string action, string message = null, bool error = true, object routeValues = null) where TViewModel : class, new()
        {
            var viewModel = new TViewModel();

            PropertyMapper <TPostModel, TViewModel> .Map(postModel, viewModel);

            ViewData.Model = viewModel;

            if (!message.IsNullOrEmpty())
            {
                ViewData.SetNotification(error ? UiNotification.Error(message) : UiNotification.Confirmation(message));
            }

            return(routeValues == null?RedirectToAction(action) : RedirectToAction(action, routeValues));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Send Notification to specific user
        /// </summary>
        /// <param name="emails"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task SendNotification(IList <string> emails, UiNotification message)
        {
            var connections = new List <string>();

            foreach (var email in emails)
            {
                if (!Connections.TryGetValue(email.Trim(), out var connectionToSendMessage))
                {
                    continue;
                }
                if (!string.IsNullOrWhiteSpace(connectionToSendMessage))
                {
                    connections.Add(connectionToSendMessage);
                }
            }
            await _hubContext.Clients.Clients(connections).ReceiveNotification(message);
        }
Exemplo n.º 4
0
 public void ErrorNotification(string unencodedMessage)
 {
     ViewData.SetNotification(UiNotification.Error(unencodedMessage));
 }
Exemplo n.º 5
0
 protected void ErrorNotification(MvcHtmlString message)
 {
     ViewData.SetNotification(UiNotification.Error(message));
 }
Exemplo n.º 6
0
 protected void InfoNotification(string message)
 {
     ViewData.SetNotification(UiNotification.Info(message));
 }
Exemplo n.º 7
0
 protected void InfoNotification(MvcHtmlString unencodedMessage)
 {
     ViewData.SetNotification(UiNotification.Info(unencodedMessage));
 }
Exemplo n.º 8
0
 protected void ConfirmationNotification(string unencodedMessage)
 {
     ViewData.SetNotification(UiNotification.Confirmation(unencodedMessage));
 }
Exemplo n.º 9
0
 protected void ConfirmationNotification(MvcHtmlString message)
 {
     ViewData.SetNotification(UiNotification.Confirmation(message));
 }
Exemplo n.º 10
0
 public static void SetNotification(this ViewDataDictionary viewData, UiNotification uiNotification)
 {
     viewData[NotificationKey] = uiNotification;
 }