コード例 #1
0
        private async Task <DefaultResult <CheckInsertInconsistenciesResponse> > CheckInsertInconsistenciesAsync(CharacterRequest characterRequest)
        {
            var defaultResult = new DefaultResult <CheckInsertInconsistenciesResponse>();

            var potterApiCharacter = (await _potterApiCharacterService.GetByNameAsync(characterRequest.Name)).FirstOrDefault();

            if (potterApiCharacter == null)
            {
                defaultResult.SetMessage(string.Format(CharacterMessages.NotExistsInPotterApi, characterRequest.Name));
                return(defaultResult);
            }

            var houseInconsistencies = await _houseService.CheckHouseInconsistenciesAsync(characterRequest, potterApiCharacter._id);

            if (!houseInconsistencies.Success)
            {
                defaultResult.SetMessages(houseInconsistencies.Messages);
                return(defaultResult);
            }

            defaultResult.SetData(new CheckInsertInconsistenciesResponse()
            {
                Id    = potterApiCharacter._id,
                House = houseInconsistencies.Data
            });

            return(defaultResult);
        }