public List <Domain.QueryView> Query(Func <QueryDescriptor <Domain.QueryView>, QueryDescriptor <Domain.QueryView> > container) { QueryDescriptor <Domain.QueryView> q = container(QueryDescriptorBuilder.Build <Domain.QueryView>()); var datas = _queryViewRepository.Query(q); WrapLocalizedLabel(datas); return(datas); }
public bool UpdateDefault(Guid entityId, Guid queryViewId) { Guard.NotEmpty(entityId, nameof(entityId)); Guard.NotEmpty(queryViewId, nameof(queryViewId)); //其他记录设置为非默认 var context = UpdateContextBuilder.Build <Domain.QueryView>(); context.Set(f => f.IsDefault, false); context.Where(f => f.EntityId == entityId); _queryViewRepository.Update(context); //设置为默认 context = UpdateContextBuilder.Build <Domain.QueryView>(); context.Set(f => f.IsDefault, true) .Set(f => f.AuthorizationEnabled, false) .Set(f => f.ModifiedOn, DateTime.Now) .Set(f => f.ModifiedBy, _currentUser.SystemUserId); context.Where(f => f.QueryViewId == queryViewId); var result = true; using (UnitOfWork.Build(_queryViewRepository.DbContext)) { _queryViewRepository.Update(context); _eventPublisher.Publish(new AuthorizationStateChangedEvent { ObjectId = new List <Guid> { queryViewId } , State = false , ResourceName = QueryViewDefaults.ModuleName }); //set to cache var items = _queryViewRepository.Query(f => f.EntityId == entityId).ToList(); foreach (var item in items) { _cacheService.SetEntity(item); } } return(result); }
public bool DeleteById(params Guid[] id) { Guard.NotEmpty(id, nameof(id)); var result = true; var deleteds = _queryViewRepository.Query(x => x.QueryViewId.In(id)); if (deleteds.NotEmpty()) { result = DeleteCore(deleteds, (deleted) => { if (deleted.IsDefault) { return(false); } //检查依赖项 _dependencyChecker.CheckAndThrow <Domain.QueryView>(QueryViewDefaults.ModuleName, deleted.QueryViewId); return(true); }); } return(result); }