public async Task <ResultDto <AuthenticatedDto> > LoginAdmin(AuthDto authDto) { var success = await _signInManager.PasswordSignInAsync(authDto.Email, authDto.Senha, false, false); if (!success.Succeeded) { return(ResultDto <AuthenticatedDto> .Validation("Login ou senha inválidos!")); } var applicationUser = await GetUserByEmail(authDto.Email); if (applicationUser.Role != "Administrador") { return(ResultDto <AuthenticatedDto> .Validation("Perfil não é Administrador!")); } var userDto = new UserDto { Id = applicationUser.Id, Nome = applicationUser.Nome, Email = applicationUser.Email, Role = applicationUser.Role, Claims = applicationUser.Claims }; return(ResultDto <AuthenticatedDto> .Success(TokenWrite.WriteToken(userDto, _tokenConfigurations, _signingConfigurations))); }
public override ConstraintDefinition CreatePropertyExistenceConstraint(Label label, params string[] propertyKeys) { KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { try { TokenWrite tokenWrite = transaction.TokenWrite(); int labelId = tokenWrite.LabelGetOrCreateForName(label.Name()); int[] propertyKeyIds = getOrCreatePropertyKeyIds(tokenWrite, propertyKeys); transaction.SchemaWrite().nodePropertyExistenceConstraintCreate(forLabel(labelId, propertyKeyIds)); return(new NodePropertyExistenceConstraintDefinition(this, label, propertyKeys)); } catch (Exception e) when(e is AlreadyConstrainedException || e is CreateConstraintFailureException || e is RepeatedSchemaComponentException) { throw new ConstraintViolationException(e.getUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (TooManyLabelsException e) { throw new System.InvalidOperationException(e); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ConstraintViolationException(e.Message, e); } } }
public async Task <ResultDto <AuthenticatedDto> > Login(AuthDto authDto) { var success = await _signInManager.PasswordSignInAsync(authDto.Email, authDto.Senha, false, false); if (!success.Succeeded) { return(ResultDto <AuthenticatedDto> .Validation("Login ou senha inválidos!")); } var applicationUser = await GetUserByEmail(authDto.Email); if (!applicationUser.Estabelecimentos.Any(x => x.EstabelecimentoId == authDto.EstabelecimentoId)) { return(ResultDto <AuthenticatedDto> .Validation("Usuário não vinculado ao estabalecimento!")); } var userDto = new UserDto { Id = applicationUser.Id, Nome = applicationUser.Nome, Email = applicationUser.Email, Role = applicationUser.Role, Claims = applicationUser.Claims, EstabelecimentoId = authDto.EstabelecimentoId, EstabelecimentoNomeUrl = applicationUser.Estabelecimentos.FirstOrDefault(x => x.EstabelecimentoId == authDto.EstabelecimentoId).Url, EstabelecimentoNome = applicationUser.Estabelecimentos.FirstOrDefault(x => x.EstabelecimentoId == authDto.EstabelecimentoId).Nome }; return(ResultDto <AuthenticatedDto> .Success(TokenWrite.WriteToken(userDto, _tokenConfigurations, _signingConfigurations))); }
public override ConstraintDefinition CreatePropertyExistenceConstraint(RelationshipType type, string propertyKey) { KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { try { TokenWrite tokenWrite = transaction.TokenWrite(); int typeId = tokenWrite.RelationshipTypeGetOrCreateForName(type.Name()); int[] propertyKeyId = getOrCreatePropertyKeyIds(tokenWrite, propertyKey); transaction.SchemaWrite().relationshipPropertyExistenceConstraintCreate(SchemaDescriptorFactory.forRelType(typeId, propertyKeyId)); return(new RelationshipPropertyExistenceConstraintDefinition(this, type, propertyKey)); } catch (Exception e) when(e is AlreadyConstrainedException || e is CreateConstraintFailureException || e is RepeatedSchemaComponentException) { throw new ConstraintViolationException(e.getUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ConstraintViolationException(e.Message, e); } } }
public override IndexDefinition CreateIndexDefinition(Label label, Optional <string> indexName, params string[] propertyKeys) { KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { try { TokenWrite tokenWrite = transaction.TokenWrite(); int labelId = tokenWrite.LabelGetOrCreateForName(label.Name()); int[] propertyKeyIds = getOrCreatePropertyKeyIds(tokenWrite, propertyKeys); LabelSchemaDescriptor descriptor = forLabel(labelId, propertyKeyIds); IndexReference indexReference = transaction.SchemaWrite().indexCreate(descriptor, indexName); return(new IndexDefinitionImpl(this, indexReference, new Label[] { label }, propertyKeys, false)); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ConstraintViolationException(e.GetUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void createKeys() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateKeys() { TokenWrite tokenWrite = TokenWriteInNewTransaction(); this._labelId = tokenWrite.LabelGetOrCreateForName("Person"); this._propertyId1 = tokenWrite.PropertyKeyGetOrCreateForName("foo"); this._propertyId2 = tokenWrite.PropertyKeyGetOrCreateForName("bar"); Commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void createKeys() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateKeys() { TokenWrite tokenWrite = tokenWriteInNewTransaction(); this.TypeId = InitializeLabelOrRelType(tokenWrite, KEY); this.PropertyKeyId = tokenWrite.PropertyKeyGetOrCreateForName(PROP); this.Descriptor = MakeDescriptor(TypeId, PropertyKeyId); commit(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void createIndexForAnotherLabelWhileHoldingSharedLockOnOtherLabel() throws org.neo4j.internal.kernel.api.exceptions.KernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateIndexForAnotherLabelWhileHoldingSharedLockOnOtherLabel() { TokenWrite tokenWrite = TokenWriteInNewTransaction(); int label2 = tokenWrite.LabelGetOrCreateForName("Label2"); Write write = DataWriteInNewTransaction(); long nodeId = write.NodeCreate(); write.NodeAddLabel(nodeId, label2); SchemaWriteInNewTransaction().indexCreate(_descriptor); Commit(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void getOrCreateIds() throws org.neo4j.internal.kernel.api.exceptions.KernelException private void getOrCreateIds() { using (Transaction tx = _graphDb.beginTx()) { ThreadToStatementContextBridge bridge = _graphDb.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)); TokenWrite tokenWrite = bridge.GetKernelTransactionBoundToThisThread(true).tokenWrite(); _labelId = tokenWrite.LabelGetOrCreateForName("Person"); _relTypeId = tokenWrite.RelationshipTypeGetOrCreateForName("Knows"); _propertyKeyId = tokenWrite.PropertyKeyGetOrCreateForName("name"); _relPropertyKeyId = tokenWrite.PropertyKeyGetOrCreateForName("duration"); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void createLabelAndProperty() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateLabelAndProperty() { TokenWrite tokenWrites = TokenWriteInNewTransaction(); _labelId = tokenWrites.LabelGetOrCreateForName(LABEL); _labelId2 = tokenWrites.LabelGetOrCreateForName(LABEL2); _relType = tokenWrites.RelationshipTypeGetOrCreateForName(REL_TYPE); _relType2 = tokenWrites.RelationshipTypeGetOrCreateForName(REL_TYPE2); _propertyKeyId = tokenWrites.PropertyKeyGetOrCreateForName(PROPERTY_KEY); _propertyKeyId2 = tokenWrites.PropertyKeyGetOrCreateForName(PROPERTY_KEY2); _descriptor = SchemaDescriptorFactory.forLabel(_labelId, _propertyKeyId); _descriptor2 = SchemaDescriptorFactory.forLabel(_labelId, _propertyKeyId2); Commit(); _executorService = Executors.newCachedThreadPool(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @BeforeClass public static void initStorage() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public static void InitStorage() { using (Transaction transaction = Db.beginTx()) { TokenWrite tokenWrite = Transaction.tokenWrite(); tokenWrite.PropertyKeyGetOrCreateForName(PROP1); tokenWrite.PropertyKeyGetOrCreateForName(PROP2); tokenWrite.LabelGetOrCreateForName(LABEL1); tokenWrite.LabelGetOrCreateForName(LABEL2); tokenWrite.RelationshipTypeGetOrCreateForName(TYPE1); transaction.Success(); } SchemaStore schemaStore = ResolveDependency(typeof(RecordStorageEngine)).testAccessNeoStores().SchemaStore; _storage = new SchemaStorage(schemaStore); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 10_000) public void createIndexesForDifferentLabelsConcurrently() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateIndexesForDifferentLabelsConcurrently() { TokenWrite tokenWrite = TokenWriteInNewTransaction(); int label2 = tokenWrite.LabelGetOrCreateForName("Label2"); LabelSchemaDescriptor anotherLabelDescriptor = SchemaDescriptorFactory.forLabel(label2, _propertyKeyId); SchemaWriteInNewTransaction().indexCreate(anotherLabelDescriptor); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.Future<?> indexFuture = executorService.submit(createIndex(db, label(LABEL), PROPERTY_KEY)); Future <object> indexFuture = _executorService.submit(CreateIndex(Db, label(LABEL), PROPERTY_KEY)); indexFuture.get(); Commit(); }
public override ConstraintDefinition CreateNodeKeyConstraint(IndexDefinition indexDefinition) { if (indexDefinition.MultiTokenIndex) { throw new ConstraintViolationException("A node key constraint does not support multi-token index definitions. " + "That is, only a single label is supported, but the following labels were provided: " + labelNameList(indexDefinition.Labels, "", ".")); } KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { try { TokenWrite tokenWrite = transaction.TokenWrite(); int labelId = tokenWrite.LabelGetOrCreateForName(single(indexDefinition.Labels).name()); int[] propertyKeyIds = getOrCreatePropertyKeyIds(tokenWrite, indexDefinition); transaction.SchemaWrite().nodeKeyConstraintCreate(forLabel(labelId, propertyKeyIds)); return(new NodeKeyConstraintDefinition(this, indexDefinition)); } catch (Exception e) when(e is AlreadyConstrainedException || e is CreateConstraintFailureException || e is AlreadyIndexedException || e is RepeatedSchemaComponentException) { throw new ConstraintViolationException(e.getUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (TooManyLabelsException e) { throw new System.InvalidOperationException(e); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ConstraintViolationException(e.Message, e); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: abstract int initializeLabelOrRelType(org.neo4j.internal.kernel.api.TokenWrite tokenWrite, String name) throws org.neo4j.internal.kernel.api.exceptions.KernelException; internal abstract int InitializeLabelOrRelType(TokenWrite tokenWrite, string name);
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: int initializeLabelOrRelType(org.neo4j.internal.kernel.api.TokenWrite tokenWrite, String name) throws org.neo4j.internal.kernel.api.exceptions.KernelException internal override int InitializeLabelOrRelType(TokenWrite tokenWrite, string name) { return(tokenWrite.LabelGetOrCreateForName(name)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static int[] getOrCreatePropertyKeyIds(org.neo4j.internal.kernel.api.TokenWrite tokenWrite, String... propertyKeys) throws org.neo4j.internal.kernel.api.exceptions.schema.IllegalTokenNameException public static int[] GetOrCreatePropertyKeyIds(TokenWrite tokenWrite, params string[] propertyKeys) { int[] propertyKeyIds = new int[propertyKeys.Length]; tokenWrite.PropertyKeyGetOrCreateForNames(propertyKeys, propertyKeyIds); return(propertyKeyIds); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static int[] getOrCreatePropertyKeyIds(org.neo4j.internal.kernel.api.TokenWrite tokenWrite, org.neo4j.graphdb.schema.IndexDefinition indexDefinition) throws org.neo4j.internal.kernel.api.exceptions.schema.IllegalTokenNameException public static int[] GetOrCreatePropertyKeyIds(TokenWrite tokenWrite, IndexDefinition indexDefinition) { return(GetOrCreatePropertyKeyIds(tokenWrite, GetPropertyKeysArrayOf(indexDefinition))); }
public async Task <ResultDto <AuthenticatedDto> > LoginSocial(AuthDto authDto) { var success = await _signInManager.PasswordSignInAsync(authDto.Email, authDto.Senha, false, false); UserDto userDto; if (!success.Succeeded) { var result = await SalvarCliente(new UserDto() { Email = authDto.Email, Senha = authDto.Senha, Nome = authDto.Nome, EstabelecimentoId = authDto.EstabelecimentoId, IsFacebook = authDto.IsFacebook, IsGoogle = authDto.IsGoogle }); if (result.StatusCode != 200) { return(await Task.FromResult(ResultDto <AuthenticatedDto> .Validation(result.Errors))); } userDto = result.Data; } else { var applicationUser = await GetUserByEmail(authDto.Email); if (!applicationUser.Estabelecimentos.Any(x => x.EstabelecimentoId == authDto.EstabelecimentoId)) { var user = await _userManager.Users?.FirstOrDefaultAsync(u => u.Id == applicationUser.Id); var userEstabelecimento = new UserEstabelecimento() { EstabelecimentoId = authDto.EstabelecimentoId }; user.AdicionarEstabelecimento(userEstabelecimento); await _userManager.UpdateAsync(user); applicationUser = await GetUserByEmail(authDto.Email); userDto = new UserDto { Id = applicationUser.Id, Nome = applicationUser.Nome, Email = applicationUser.Email, Role = applicationUser.Role, Claims = applicationUser.Claims, EstabelecimentoId = authDto.EstabelecimentoId, EstabelecimentoNomeUrl = applicationUser.Estabelecimentos.FirstOrDefault(x => x.EstabelecimentoId == authDto.EstabelecimentoId).Url, EstabelecimentoNome = applicationUser.Estabelecimentos.FirstOrDefault(x => x.EstabelecimentoId == authDto.EstabelecimentoId).Nome }; _emailService.Send(userDto.Email, "Confirmação de cadastro", userDto.EstabelecimentoNome, EmailTemplate.ConfirmacaoCadastro(_configuration, userDto)); } else { userDto = new UserDto { Id = applicationUser.Id, Nome = applicationUser.Nome, Email = applicationUser.Email, Role = applicationUser.Role, Claims = applicationUser.Claims, EstabelecimentoId = authDto.EstabelecimentoId, EstabelecimentoNomeUrl = applicationUser.Estabelecimentos.FirstOrDefault(x => x.EstabelecimentoId == authDto.EstabelecimentoId).Url, EstabelecimentoNome = applicationUser.Estabelecimentos.FirstOrDefault(x => x.EstabelecimentoId == authDto.EstabelecimentoId).Nome }; } } return(ResultDto <AuthenticatedDto> .Success(TokenWrite.WriteToken(userDto, _tokenConfigurations, _signingConfigurations))); }