示例#1
0
        public async Task AddNotificationTransport(NotificationTransport transport)
        {
            DeleteOldNotificationTransports(transport.GetType(), transport.UserId);

            transport.IsDeleted = false;
            db.NotificationTransports.Add(transport);

            await db.SaveChangesAsync();
        }
示例#2
0
        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();
            }
        }
示例#3
0
        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();
            }
        }