Esempio n. 1
0
        public async Task <IActionResult> AddIfNotExistsCharacter(CharacterToAddDTO characterToAdd)
        {
            if (await _characterRepository.CharacterExists(characterToAdd))
            {
                // 409 conflict seems to be most appropriate status code
                return(StatusCode(409));
            }

            var character = new Character
            {
                Name     = characterToAdd.Name,
                Realm    = characterToAdd.Realm,
                Region   = characterToAdd.Region,
                Class    = characterToAdd.Class,
                FullName = characterToAdd.FullName,
            };

            var addedCharacter = await _characterRepository.Add(character);

            return(StatusCode(201));
        }