Example #1
0
        public JsonResult GetById(int id)
        {
            var dbCharacter = _characterService.GetById(id);

            if (dbCharacter == null)
            {
                return(ErrorResponse("Not found"));
            }

            return(SingleResult(CharacterViewModelHelpers.ConvertToviewModel(dbCharacter)));
        }
Example #2
0
        public JsonResult GetByName(string characterName)
        {
            if (string.IsNullOrWhiteSpace(characterName))
            {
                return(ErrorResponse("Character name is required"));
            }

            var character = _characterService.GetByName(characterName);

            if (character == null)
            {
                return(ErrorResponse("No character found"));
            }

            return(SingleResult(CharacterViewModelHelpers.ConvertToviewModel(character)));
        }