public async Task <TEntity> UpdateAsync(TEntity updated) { try { if (updated == null) { return(null); } var existing = await _context.Set <TEntity>().FindAsync(updated.CommentKey); if (existing != null) { _context.Entry(existing).CurrentValues.SetValues(updated); await _context.SaveChangesAsync(); } else { throw new CommandServiceException($"Missing entity {updated.CommentKey}"); } return(existing); } catch (Exception ex) { SaveError(ex); return(null); } }
public void Update(T entity) { _dbContext.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Modified; }