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)); }
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)); }
/// <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); }
public void ErrorNotification(string unencodedMessage) { ViewData.SetNotification(UiNotification.Error(unencodedMessage)); }
protected void ErrorNotification(MvcHtmlString message) { ViewData.SetNotification(UiNotification.Error(message)); }
protected void InfoNotification(string message) { ViewData.SetNotification(UiNotification.Info(message)); }
protected void InfoNotification(MvcHtmlString unencodedMessage) { ViewData.SetNotification(UiNotification.Info(unencodedMessage)); }
protected void ConfirmationNotification(string unencodedMessage) { ViewData.SetNotification(UiNotification.Confirmation(unencodedMessage)); }
protected void ConfirmationNotification(MvcHtmlString message) { ViewData.SetNotification(UiNotification.Confirmation(message)); }
public static void SetNotification(this ViewDataDictionary viewData, UiNotification uiNotification) { viewData[NotificationKey] = uiNotification; }