public JsonResult GetById(int id) { var dbCharacter = _characterService.GetById(id); return(dbCharacter == null ? ErrorResponse("Not found") : SingleResult(CharacterViewModelHelpers.ConvertToViewModel(dbCharacter.CharacterName))); }
public JsonResult GetById(int id) { var dbCharacter = _characterService.GetById(id); if (dbCharacter == null) { return(ErrorResponse("Not found")); } return(SingleResult(CharacterViewModelHelpers.ConvertToViewModel(dbCharacter))); }
public JsonResult Search(string searchString) { var foundCharacters = _characterService .Search(searchString).ToList(); return(!foundCharacters.Any() ? ErrorResponse("No Characters found") : MultipleResults(foundCharacters .Select(character => CharacterViewModelHelpers .ConvertToViewModel(character.Key, character.ToDictionary(bc => bc.Book.BookOrdinal, bc => bc.Book.BookName))))); }
public JsonResult GetByName(string characterName) { if (string.IsNullOrWhiteSpace(characterName)) { return(ErrorResponse("Character name is required")); } var character = _characterService.GetByName(characterName); return(character == null ? ErrorResponse("No character found") : SingleResult(CharacterViewModelHelpers.ConvertToViewModel(character.CharacterName))); }