Example #1
0
        public bool DisassociateFile(Guid sourceId, string moduleKey, string sourceType = "")
        {
            using (var dbContext = new SystemSettingsDbContext())
            {
                var sourceTypeIsNull = string.IsNullOrWhiteSpace(sourceType);
                var entitys          = dbContext.StorageFileRelations.Where(r => r.SourceId == sourceId && r.ModuleKey.Equals(moduleKey, StringComparison.OrdinalIgnoreCase) && (sourceTypeIsNull || r.SourceType.Equals(sourceType, StringComparison.OrdinalIgnoreCase))).ToList();
                entitys.ForEach(m => dbContext.Entry(m).State = EntityState.Deleted);

                return(dbContext.SaveChanges() > 0);
            }
        }
Example #2
0
        public bool DeleteBySourceType(string sourceType)
        {
            if (string.IsNullOrWhiteSpace(sourceType))
            {
                return(false);
            }

            using (var dbContext = new SystemSettingsDbContext())
            {
                var entitys = dbContext.StorageFileRelations.Where(r => r.SourceType.Equals(sourceType, StringComparison.OrdinalIgnoreCase)).ToList();
                entitys.ForEach(m => dbContext.Entry(m).State = EntityState.Deleted);

                return(dbContext.SaveChanges() > 0);
            }
        }