public void Delete(T entity) { try { _databaseContext.Remove(entity); _databaseContext.SaveChanges(); } catch (Exception ex) { _logger.LogError("Error while removing entity.", ex); throw; } }
public void Delete(T entity, bool createEvent = true) { try { _databaseContext.Remove(entity); _databaseContext.SaveChanges(); if (createEvent) { _logger.LogDebug("Publish delete event for " + entity.Id); _messageBroker.Publish(DeleteQueue, new EntityDeletedEvent { EmmitedServerId = _serverDescriptor.Id, Id = entity.Id }); } } catch (Exception ex) { _logger.LogError("Error while removing entity.", ex); throw; } }