public ActionResult RemoveNotification(string ID, string authorize) { string message = string.Empty; if (string.IsNullOrWhiteSpace(authorize) || !ID.ToString().Equals(authorize)) { message = "You must check the proper authorize radio button first."; } else { string userId = User.Identity.GetUserId(); ApplicationUser authedUser = UserManager.FindById(userId); IPlayerMessage notification = authedUser.GameAccount.Config.Notifications.FirstOrDefault(ch => ch.UniqueKey.Equals(ID)); if (notification == null) { message = "That message does not exist"; } else if (notification.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User))) { message = "Message successfully deleted."; } else { message = "Error. Message not removed."; } } return(RedirectToAction("Notifications", new { Message = message })); }
public ActionResult MarkAsReadNotification(string id, AddViewNotificationViewModel vModel) { string message = string.Empty; string userId = User.Identity.GetUserId(); ApplicationUser authedUser = UserManager.FindById(userId); try { if (!string.IsNullOrWhiteSpace(id)) { IPlayerMessage notification = ConfigDataCache.Get <IPlayerMessage>(id); if (notification != null) { notification.Read = true; notification.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } } else { message = "Invalid message."; } } catch (Exception ex) { LoggingUtility.LogError(ex, LogChannels.SystemWarnings); } return(RedirectToAction("Notifications", new { Message = message })); }
private void GetNotifications(DataAccess.FileSystem.ConfigData dataAccessor, DirectoryInfo charDirectory) { try { IEnumerable <FileInfo> files = charDirectory.EnumerateFiles("*.PlayerMessage", SearchOption.TopDirectoryOnly); List <IPlayerMessage> dataList = new List <IPlayerMessage>(); foreach (FileInfo file in files) { if (file == null) { continue; } IPlayerMessage newMessage = (IPlayerMessage)dataAccessor.ReadEntity(file, typeof(IPlayerMessage)); if (newMessage != null) { ConfigDataCache.Add(newMessage); dataList.Add(newMessage); } } Notifications = dataList; } catch (Exception ex) { LoggingUtility.LogError(ex); //Let it keep going } }
internal void MessagePlayer(int playerIndex, IPlayerMessage message) { if (Players.TryGetValue(playerIndex, out var messageStack)) { messageStack.Push(message); } }
public ActionResult AddViewNotification(string id) { string userId = User.Identity.GetUserId(); AddViewNotificationViewModel model = new AddViewNotificationViewModel { AuthedUser = UserManager.FindById(userId) }; if (!string.IsNullOrWhiteSpace(id)) { IPlayerMessage message = ConfigDataCache.Get <IPlayerMessage>(id); if (message != null) { model.DataObject = message; model.Body = message.Body; model.Recipient = message.RecipientName; model.Subject = message.Subject; } } return(View(model)); }