public async Task AddNotificationTransport(NotificationTransport transport) { DeleteOldNotificationTransports(transport.GetType(), transport.UserId); transport.IsDeleted = false; db.NotificationTransports.Add(transport); await db.SaveChangesAsync(); }
public async Task AddNotificationTransport(NotificationTransport transport) { using (var transaction = db.Database.BeginTransaction()) { await DeleteOldNotificationTransports(transport.GetType(), transport.UserId); transport.IsDeleted = false; db.NotificationTransports.Add(transport); await db.SaveChangesAsync(); await transaction.CommitAsync(); } }
public async Task AddNotificationTransport(NotificationTransport transport) { using (var transaction = db.Database.BeginTransaction()) { DeleteOldNotificationTransports(transport.GetType(), transport.UserId); /* * if (transport is MailNotificationTransport) * DeleteOldNotificationTransports<MailNotificationTransport>(transport.UserId); * if (transport is TelegramNotificationTransport) * DeleteOldNotificationTransports<TelegramNotificationTransport>(transport.UserId); */ transport.IsDeleted = false; db.NotificationTransports.Add(transport); await db.SaveChangesAsync().ConfigureAwait(false); transaction.Commit(); } }