Example #1
0
        public void DeleteToken(string app, Guid?userId = null)
        {
            var apps = FilesDbContext.ThirdpartyApp
                       .Where(r => r.TenantId == TenantManager.GetCurrentTenant().TenantId)
                       .Where(r => r.UserId == (userId ?? AuthContext.CurrentAccount.ID))
                       .Where(r => r.App == app);

            FilesDbContext.RemoveRange(apps);
            FilesDbContext.SaveChanges();
        }
Example #2
0
        public void RemoveSubject(Guid subject)
        {
            using var tr = FilesDbContext.Database.BeginTransaction();

            var toDelete1 = FilesDbContext.Security.Where(r => r.Subject == subject);
            var toDelete2 = FilesDbContext.Security.Where(r => r.Owner == subject);

            FilesDbContext.RemoveRange(toDelete1);
            FilesDbContext.SaveChanges();

            FilesDbContext.RemoveRange(toDelete2);
            FilesDbContext.SaveChanges();

            tr.Commit();
        }
Example #3
0
        public void DeleteShareRecords(IEnumerable <FileShareRecord> records)
        {
            using var tx = FilesDbContext.Database.BeginTransaction();

            foreach (var record in records)
            {
                var query = FilesDbContext.Security
                            .Where(r => r.TenantId == record.Tenant)
                            .Where(r => r.EntryId == MappingID(record.EntryId).ToString())
                            .Where(r => r.EntryType == record.EntryType)
                            .Where(r => r.Subject == record.Subject);

                FilesDbContext.RemoveRange(query);
            }

            tx.Commit();
        }