/// <summary> /// Does this person want this notification /// </summary> /// <param name="playerName">The player's name who's triggering the notification</param> /// <param name="isGossipSystem">Is this the gossip system</param> /// <param name="type">what type of notification is this</param> /// <returns>Whether or not they want it</returns> public bool WantsNotification(string playerName, bool isGossipSystem, AcquaintenceNotifications type) { return(Acquaintences.Any(acq => acq.IsFriend && acq.PersonHandle.Equals(playerName, StringComparison.InvariantCultureIgnoreCase) && acq.NotificationSubscriptions.Contains(type) && isGossipSystem == acq.GossipSystem)); }
public ActionResult AddAcquaintence(string AcquaintenceName, bool IsFriend, bool GossipSystem, string Notifications) { string message = string.Empty; string userId = User.Identity.GetUserId(); ApplicationUser authedUser = UserManager.FindById(userId); if (AcquaintenceName.Equals(authedUser.GlobalIdentityHandle, StringComparison.InvariantCultureIgnoreCase)) { message = "You can't become an acquaintence of yourself."; } else { List <AcquaintenceNotifications> notificationsList = new List <AcquaintenceNotifications>(); foreach (string notification in Notifications.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries)) { AcquaintenceNotifications anShort = (AcquaintenceNotifications)Enum.Parse(typeof(AcquaintenceNotifications), notification); notificationsList.Add(anShort); } Acquaintence newAcq = new Acquaintence { PersonHandle = AcquaintenceName, IsFriend = IsFriend, GossipSystem = GossipSystem, NotificationSubscriptions = notificationsList.ToArray() }; List <IAcquaintence> acquaintences = authedUser.GameAccount.Config.Acquaintences.ToList(); if (acquaintences.Any(aq => aq.PersonHandle == newAcq.PersonHandle)) { acquaintences.Remove(newAcq); } acquaintences.Add(newAcq); authedUser.GameAccount.Config.Acquaintences = acquaintences; if (authedUser.GameAccount.Config.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { message = "Acquaintence successfully added."; } else { message = "Error. Acquaintence not added."; } } return(RedirectToAction("Acquaintences", new { Message = message })); }