public void ArchiveKafkaProducerMessage(int messageId) { KafkaProducerMessage m = context.KafkaProducerMessage.Find(messageId); KafkaProducerMessageArchive archivedMessage = KafkaProducerMessageToKafkaProducerMessageArchive(m); using (var dbContextTransaction = context.Database.BeginTransaction()) { try { context.KafkaProducerMessageArchive.Add(archivedMessage); context.KafkaProducerMessage.Remove(m); dbContextTransaction.Commit(); context.SaveChanges(); } catch (Exception) { dbContextTransaction.Rollback(); context.SaveChanges(); } } }
public static KafkaProducerMessageArchive KafkaProducerMessageToKafkaProducerMessageArchive(KafkaProducerMessage message) { return(new KafkaProducerMessageArchive { KafkaProducerMessageId = message.KafkaProducerMessageId, Content = message.Content, Topic = message.Topic, CreatedTime = message.CreatedTime, ArchivedTime = DateTime.UtcNow }); }
public void InsertKafkaProducerMessage(KafkaProducerMessage message) { context.KafkaProducerMessage.Add(message); context.SaveChanges(); }