public async Task testRealizandoCrudJogador() { using (var context = _serviceProvider.GetService <MyContext>()) { //INsert JogadorImplementation _repositorio = new JogadorImplementation(context); JogadorEntity _entity = new JogadorEntity { Nome = "Bento", Cidade = "São Carlos", }; var _registroCriado = await _repositorio.InsertAsync(_entity); Assert.NotNull(_registroCriado); Assert.Equal(_entity.Nome, _registroCriado.Nome); //Update _entity.Nome = Faker.Name.First(); var _registroAtualizado = await _repositorio.UpdateAsync(_entity); Assert.NotNull(_registroAtualizado); Assert.Equal(_entity.Nome, _registroAtualizado.Nome); //Selecao var _registroSelecao = await _repositorio.SelectAsync(_registroAtualizado.Id); Assert.NotNull(_registroSelecao); //Delete var _registroRemovido = await _repositorio.DeleteAsync(_registroAtualizado.Id); Assert.True(_registroRemovido); } }
public async Task <IActionResult> Edit(int id, JogadorEntity jogadorEntity, string imagemAntiga) { if (id != jogadorEntity.Id) { return(NotFound()); } if (ModelState.IsValid) { try { await _domainService.UpdateAsync(jogadorEntity, imagemAntiga); } catch (DbUpdateConcurrencyException) { if (!AmigoEntityExists(jogadorEntity.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(jogadorEntity)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Time,FreeAgent,ImageUri")] JogadorEntity jogadorEntity) { if (id != jogadorEntity.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(jogadorEntity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JogadorEntityExists(jogadorEntity.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(jogadorEntity)); }
public async Task <IActionResult> Create([Bind("Id,Nome,Time,FreeAgent,ImageUri")] JogadorEntity jogadorEntity) { if (ModelState.IsValid) { _context.Add(jogadorEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(jogadorEntity)); }
public async Task <IActionResult> Create(JogadorEntity jogadorEntity) { if (ModelState.IsValid) { var image = jogadorEntity.ImageUri; await _domainService.InsertAsync(jogadorEntity); return(RedirectToAction(nameof(Index))); } return(View(jogadorEntity)); }
public async Task InsertAsync(JogadorEntity jogadorEntity) { await _repository.InsertAsync(jogadorEntity); var message = new { ImageURI = jogadorEntity.ImageUri, Id = $"{jogadorEntity.Id}", }; var jsonMessage = JsonConvert.SerializeObject(message); var bytesJsonMessage = UTF8Encoding.UTF8.GetBytes(jsonMessage); string jsonMessageBase64 = Convert.ToBase64String(bytesJsonMessage); await _queueService.SendAsync(jsonMessageBase64); await _historicoRepository.InsertAsync(new JogadorHistoricoEntity(jogadorEntity)); }
public async Task UpdateAsync(JogadorEntity jogadorEntity, string novaImagem) { if (jogadorEntity.ImageUri != null) { await _blobService.DeleteAsync(jogadorEntity.ImageUri); var message = new { ImageURI = novaImagem, Id = $"{jogadorEntity.Id}", }; var jsonMessage = JsonConvert.SerializeObject(message); var bytesJsonMessage = UTF8Encoding.UTF8.GetBytes(jsonMessage); string jsonMessageBase64 = Convert.ToBase64String(bytesJsonMessage); await _queueService.SendAsync(jsonMessageBase64); } await _repository.UpdateAsync(jogadorEntity); await _historicoRepository.InsertAsync(new JogadorHistoricoEntity(jogadorEntity)); }
public async Task DeleteAsync(JogadorEntity jogadorEntity) { await _blobService.DeleteAsync(jogadorEntity.ImageUri); await _repository.DeleteAsync(jogadorEntity); }
public async Task DeleteAsync(JogadorEntity jogadorEntity) { _context.Remove(jogadorEntity); await _context.SaveChangesAsync(); }
public async Task UpdateAsync(JogadorEntity jogadorEntity) { _context.Update(jogadorEntity); await _context.SaveChangesAsync(); }
public async Task InsertAsync(JogadorEntity jogadorEntity) { _context.Add(jogadorEntity); await _context.SaveChangesAsync(); }