private async void UserContext_MessageReceived(object sender, MessageEventArgs e) { var message = e.Message; var messageType = e.MessageType; var sendUserID = e.UserID; var userIDs = e.Items.Select(item => item.ID).ToArray(); if (messageType == MessageType.Notification) { if (e.UserID != this.authenticator.ID && (userIDs.Any() == false || userIDs.Any(item => item == this.authenticator.ID) == true)) { await this.Dispatcher.InvokeAsync(() => { var title = string.Format(Resources.Title_AdministratorMessage_Format, sendUserID); this.flashService?.Flash(); AppMessageBox.Show(message, title, MessageBoxButton.OK, MessageBoxImage.Information); }); } } else if (messageType == MessageType.None) { await this.Dispatcher.InvokeAsync(async() => { var userContext = this.cremaAppHost.GetService(typeof(IUserContext)) as IUserContext; var dialog = await ViewMessageViewModel.CreateInstanceAsync(this.authenticator, userContext, message, sendUserID); dialog?.ShowDialog(); }); } }
public ActionResult ViewMessage(int messageID) { if (!_messageServices.CanViewMessage(_currentUser.UserID, messageID)) { return(RedirectToAction("Inbox")); } SetBreadCrumb("View Message"); Message message = _messageServices.GetMessage(messageID); if (message.ToUserID == _currentUser.UserID && !message.IsRead) { _messageServices.MarkAsRead(messageID); } var model = new ViewMessageViewModel() { Message = message, ParsedText = _parseServices.ParseBBCodeText(message.Text), SendMessageViewModel = new SendMessageViewModel() { Username = message.FromUser.Username, Subject = "RE:" + message.Subject } }; return(View(model)); }
public async Task <IActionResult> ViewMessage(string key) { logger.LogInformation($"Attempting to retrieve message: {key}"); var message = await messageService.Retrieve(key); logger.LogInformation($"Message {key} has been removed from cache"); var viewMessageViewModel = new ViewMessageViewModel() { Message = message }; return(View(viewMessageViewModel)); }