private RPGCharacterData <TRaceType, TClassType> ConvertDbToTransit(FullCharacterData <TRaceType, TClassType> characterData) { if (characterData == null) { throw new ArgumentNullException(nameof(characterData)); } return(new RPGCharacterData <TRaceType, TClassType>(new RPGCharacterEntry(characterData.Character.Id, characterData.Character.Name), new RPGCharacterCreationDetails(characterData.Character.CreationDate), new RPGCharacterProgress(characterData.Character.Progress.Experience, characterData.Character.Progress.Level, characterData.Character.Progress.PlayTime), characterData.Definition.Race.Id, characterData.Definition.Class.Id)); }
RetrieveCharacterDataAsync([FromRoute(Name = "id")] int characterId, CancellationToken token = default) { //TODO: Properly handle failure and return correct response codes. if (await CharacterRepository.ContainsAsync(characterId, token)) { FullCharacterData <TRaceType, TClassType> characterData = await CharacterRepository.RetrieveFullCharacterDataAsync(characterId, token); return(new ResponseModel <RPGCharacterData <TRaceType, TClassType>, CharacterDataQueryResponseCode>(ConvertDbToTransit(characterData))); } else { return(new ResponseModel <RPGCharacterData <TRaceType, TClassType>, CharacterDataQueryResponseCode>(CharacterDataQueryResponseCode.CharacterDoesNotExist)); } }