Exemplo n.º 1
0
        private bool DeleteCore(IEnumerable <Chart> deleteds, Func <Chart, bool> validation)
        {
            Guard.NotEmpty(deleteds, nameof(deleteds));
            var result = true;

            if (validation != null)
            {
                foreach (var deleted in deleteds)
                {
                    result = validation?.Invoke(deleted) ?? true;
                }
            }
            if (result)
            {
                var ids = deleteds.Select(x => x.ChartId);
                using (UnitOfWork.Build(_chartRepository.DbContext))
                {
                    result = _chartRepository.DeleteMany(ids);
                    //删除依赖项
                    _dependencyService.Delete(ids.ToArray());
                    //localization
                    _localizedLabelService.DeleteByObject(ids.ToArray());
                }
            }
            return(result);
        }