コード例 #1
0
        public async Task <SavePokedexInfoResponse> UpdateAsync(int id, PokedexInfo pokedexInfo)
        {
            var existingRepository = await _pokedexInfoRepository.FindByIdAsync(id);

            if (existingRepository == null)
            {
                return(new SavePokedexInfoResponse("Informacao nao encontrada"));
            }

            existingRepository.Numero     = pokedexInfo.Numero;
            existingRepository.Name       = pokedexInfo.Name;
            existingRepository.Type_1     = pokedexInfo.Type_1;
            existingRepository.Type_2     = pokedexInfo.Type_2;
            existingRepository.Total      = pokedexInfo.Total;
            existingRepository.HP         = pokedexInfo.HP;
            existingRepository.Attack     = pokedexInfo.Attack;
            existingRepository.Defense    = pokedexInfo.Defense;
            existingRepository.SP_Atk     = pokedexInfo.SP_Atk;
            existingRepository.SP_Def     = pokedexInfo.SP_Def;
            existingRepository.Speed      = pokedexInfo.Speed;
            existingRepository.Generation = pokedexInfo.Generation;
            existingRepository.Legendary  = pokedexInfo.Legendary;

            try
            {
                _pokedexInfoRepository.Update(existingRepository);
                await _unitOfWork.CompleteAsync();

                return(new SavePokedexInfoResponse(existingRepository));
            }
            catch (Exception ex)
            {
                return(new SavePokedexInfoResponse($"Erro ao Atualizar: {ex.Message}"));
            }
        }
コード例 #2
0
        public async Task <SavePokedexInfoResponse> GetById(Guid id)
        {
            var existingRepository = await _pokedexInfoRepository.FindByIdAsync(id);

            if (existingRepository == null)
            {
                return(new SavePokedexInfoResponse("Informação não encontrada"));
            }

            return(new SavePokedexInfoResponse(existingRepository));
        }