Пример #1
0
        public JsonResult <string[]> GetCharacterNamesForAccount(string accountName, string term)
        {
            ApplicationUser user = UserManager.FindById(User.Identity.GetUserId());

            IEnumerable <IPlayerTemplate> characters = PlayerDataCache.GetAll().Where(chr => chr.AccountHandle.Equals(user.GlobalIdentityHandle) && chr.Name.Contains(term));

            return(Json(characters.Select(chr => chr.Name).ToArray()));
        }
Пример #2
0
        /// <summary>
        /// Add a character to this account
        /// </summary>
        /// <param name="newChar">the character data to add</param>
        /// <returns>errors or Empty if successful</returns>
        public string AddCharacter(IPlayerTemplate newChar)
        {
            HashSet <IPlayerTemplate> systemChars = new HashSet <IPlayerTemplate>(PlayerDataCache.GetAll());

            if (systemChars.Any(ch => ch.Name.Equals(newChar.Name, StringComparison.InvariantCultureIgnoreCase) && newChar.SurName.Equals(newChar.SurName, StringComparison.InvariantCultureIgnoreCase)))
            {
                return("A character with that name already exists, please choose another.");
            }

            newChar.AccountHandle = GlobalIdentityHandle;
            newChar.Create(this, StaffRank.Player); //characters dont need approval yet but your rank is ALWAYS player here
            systemChars.Add(newChar);

            Characters = systemChars;

            return(string.Empty);
        }