Exemplo n.º 1
0
        public void DeleteCharacter(int characterid)
        {
            var item       = default(CharacterData);
            var itemExists = false;

            foreach (var characterData in characters)
            {
                if (characterData.id == characterid)
                {
                    item       = characterData;
                    itemExists = true;
                }
            }

            var statusCode = 0;
            var json       = string.Empty;

            if (itemExists)
            {
                characters.Remove(item);

                statusCode = 200;

                DeleteCharacterCallback?.Invoke(statusCode, json);
            }
            else
            {
                statusCode = 404;
                json       = "The character was not found.";

                DeleteCharacterCallback?.Invoke(statusCode, json);
            }
        }