示例#1
0
        public bool DeleteById(params Guid[] ids)
        {
            Guard.NotEmpty(ids, nameof(ids));
            var deleteds = _entityPluginRepository.Query(x => x.EntityPluginId.In(ids.ToArray()));

            if (deleteds.IsEmpty())
            {
                return(false);
            }
            return(DeleteCore(deleteds.ToArray()));
        }
示例#2
0
        public List <EntityPlugin> QueryByEntityId(Guid entityid, string eventName, Guid?businessObjectId = null, PlugInType typeCode = PlugInType.Entity)
        {
            List <EntityPlugin> entities = _cacheService.GetVersionItems(entityid + "/" + eventName, () =>
            {
                return(_entityPluginRepository.Query(x => x.EntityId == entityid)?.ToList());
            });

            if (entities.NotEmpty())
            {
                if (businessObjectId.HasValue)
                {
                    entities.RemoveAll(x => !(x.EventName.IsCaseInsensitiveEqual(eventName) && x.BusinessObjectId == businessObjectId.Value && x.TypeCode == (int)typeCode));
                }
                else
                {
                    entities.RemoveAll(x => !(x.EventName.IsCaseInsensitiveEqual(eventName) && x.BusinessObjectId == Guid.Empty && x.TypeCode == (int)typeCode));
                }
            }
            return(entities.OrderBy(x => x.ProcessOrder).ToList());
        }
示例#3
0
        public bool UpdateState(IEnumerable <Guid> ids, bool isEnabled)
        {
            var context = UpdateContextBuilder.Build <EntityPlugin>();

            context.Set(f => f.StateCode, isEnabled ? RecordState.Enabled : RecordState.Disabled);
            context.Where(f => f.EntityPluginId.In(ids));
            var result = false;

            using (UnitOfWork.Build(_entityPluginRepository.DbContext))
            {
                result = _entityPluginRepository.Update(context);
                //set to cache
                var items = _entityPluginRepository.Query(x => x.EntityPluginId.In(ids));
                foreach (var item in items)
                {
                    _cacheService.SetEntity(item);
                }
            }
            return(result);
        }