public void RetirarPerfil(int usuarioId, int perfilId) { var dbContext = new SQLDbContext(); var parametros = new SqlParameter[] { new SqlParameter("@IdUsuario", usuarioId), new SqlParameter("@IdPerfil", perfilId) }; dbContext.ExecutarProcedure("SP_RetirarPerfil", parametros); }
private void ExecutarProcedureDoFluxo(string nomeProcedure, int clienteId, int userId) { var dbContext = new SQLDbContext(); var parametros = new SqlParameter[] { new SqlParameter("@IdCliente", clienteId), new SqlParameter("@IdUsuarioResponsavel", userId), }; dbContext.ExecutarProcedure(nomeProcedure, parametros); }
public User GetByCredentials(string login, string password) { try { User user = null; var dbContext = new SQLDbContext(); var parametros = new SqlParameter[] { new SqlParameter("@Login", login), new SqlParameter("@Senha", password), }; DataTable dtResult = dbContext.ExecutarProcedure("SP_Logar", parametros); if (dtResult.Rows.Count > 0) { DataRow dataRow = dtResult.Rows[0]; user = new User( id: Convert.ToInt32(dataRow["Id"]), name: dataRow["Nome"].ToString(), login, password, Convert.ToDateTime(dataRow["DataCadastro"]) ); var roles = _perfilRepository.GetById(user.Id); user.Roles = roles; } return(user); } catch (SqlException ex) { if (ex.Number == 50000) { throw new InvalidLoginException(ex.Message, ex); } throw ex; } }
public void Delete(int userId) { try { var dbContext = new SQLDbContext(); var parametros = new SqlParameter[] { new SqlParameter("@Id", userId), }; dbContext.ExecutarProcedure("SP_DeletarUsuario", parametros); } catch (SqlException ex) { if (ex.Number > 50000) { throw new InvalidClientException(ex.Message); } throw ex; } }
public void Insert(User user) { try { var dbContext = new SQLDbContext(); var parametros = new SqlParameter[] { new SqlParameter("@Nome", user.Name), new SqlParameter("@Login", user.Login), new SqlParameter("@Senha", user.Password), }; dbContext.ExecutarProcedure("SP_InserirUsuario", parametros); } catch (SqlException ex) { if (ex.Number > 50000) { throw new InvalidClientException(ex.Message); } throw ex; } }
public bool VerifyIfUserInFluxo(int clientId, int userId) { try { var dbContext = new SQLDbContext(); var parametros = new SqlParameter[] { new SqlParameter("@IdCliente", clientId), new SqlParameter("@IdUsuario", userId) }; dbContext.ExecutarProcedure("SP_VerificarSeUsuarioEstaEnvolvidoNoFluxo", parametros); return(false); } catch (SqlException ex) { if (ex.Number > 50000) { return(true); } throw ex; } }