//private readonly string erroAtualizarBaseReplicacao = "Não foi possível atualizar a base de replicação"; public async Task AddAsync(T obj) { try { await contextCommands.Set <T>().AddAsync(obj); retorno = await contextCommands.SaveChangesAsync(); if (retorno > 0) { await contextQueries.Set <T>().AddAsync(obj); retorno = await contextQueries.SaveChangesAsync(); if (retorno < 1) { await RemoveAsync(obj.Id); throw new Exception(erroSalvarBaseReplicacao); } } } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> PutPlatform(int id, Platform platform) { if (id != platform.Id) { return(BadRequest()); } _context.Entry(platform).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlatformExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCommand(int id, Command command) { if (id != command.Id) { return(BadRequest()); } _context.Entry(command).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommandExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }