Пример #1
0
        public virtual bool SaveMany(IList <Setting> entities)
        {
            if (entities.IsEmpty())
            {
                return(false);
            }
            var names  = entities.Select(f => f.Name);
            var result = true;

            using (UnitOfWork.Build(_settingRepository.DbContext))
            {
                _settingRepository.DeleteMany(x => x.Name.In(names));
                foreach (var item in entities)
                {
                    item.CreatedBy      = _currentUser.SystemUserId;
                    item.OrganizationId = _currentUser.OrganizationId;
                }
                result = _settingRepository.CreateMany(entities);
                //add to cache
                foreach (var deleted in entities)
                {
                    //remove from cache
                    _cache.RemoveEntity(deleted);
                }
            }
            return(result);
        }