public async Task <bool> EditarPassword(string email, string password) { try { SqlConnection _miConexion = new SqlConnection(); _miConexion.ConnectionString = this.connectionString; _miConexion.Open(); SqlCommand _insert = new SqlCommand(); _insert.Connection = _miConexion; _insert.CommandType = CommandType.Text; _insert.CommandText = "update dbo.Clientes set Password = @Password where Email = @Email"; _insert.Parameters.AddWithValue("@Email", email); _insert.Parameters.AddWithValue("@Password", StringCipher.EncryptOneWay(password)); if (await _insert.ExecuteNonQueryAsync() > 0) { return(true); } _insert.Connection.Close(); } catch (Exception) { } return(false); }
public async Task <bool> signup(Cliente client) { bool result = false; try { SqlConnection _miConexion = new SqlConnection(); _miConexion.ConnectionString = this.connectionString; _miConexion.Open(); SqlCommand _insert = new SqlCommand(); _insert.Connection = _miConexion; _insert.CommandType = CommandType.Text; _insert.CommandText = "insert into dbo.Clientes (Email,Password,Nombre,Apellidos,Movil,CuentaActiva) values (@Email,@Password,@Nombre,@Apellidos,@Movil,@CuentaActiva)"; _insert.Parameters.AddWithValue("@Email", client.Email); _insert.Parameters.AddWithValue("@Password", StringCipher.EncryptOneWay(client.Password)); _insert.Parameters.AddWithValue("@Nombre", client.DatosPersonales.Nombre); _insert.Parameters.AddWithValue("@Apellidos", client.DatosPersonales.Apellidos); _insert.Parameters.AddWithValue("@Movil", client.DatosPersonales.Movil); _insert.Parameters.AddWithValue("@CuentaActiva", false); if (await _insert.ExecuteNonQueryAsync() > 0) { _insert.Parameters.Clear(); _insert.CommandText = "insert into dbo.Direcciones (Email,CP,IdProv,IdMun,Calle) values(@Email,@CP,@IdProv,@IdMun,@Calle)"; _insert.Parameters.AddWithValue("@Email", client.Email); _insert.Parameters.AddWithValue("@CP", client.Direcciones[0].CodigoPostal); _insert.Parameters.AddWithValue("@IdProv", client.Direcciones[0].Provincia.id); _insert.Parameters.AddWithValue("@IdMun", client.Direcciones[0].Municipio.id); _insert.Parameters.AddWithValue("@Calle", client.Direcciones[0].Calle); if (await _insert.ExecuteNonQueryAsync() > 0) { result = true; _insert.Connection.Close(); } } } catch (Exception) { } return(result); }
public async Task <Cliente> login(Cliente client) { try { SqlConnection _miConexion = new SqlConnection(); _miConexion.ConnectionString = this.connectionString; _miConexion.Open(); SqlCommand _insert = new SqlCommand(); _insert.Connection = _miConexion; _insert.CommandType = CommandType.Text; _insert.CommandText = "select Nombre, Apellidos, Movil, Fijo from dbo.Clientes where Email=@Email and Password=@Password"; _insert.Parameters.AddWithValue("@Email", client.Email); _insert.Parameters.AddWithValue("@Password", StringCipher.EncryptOneWay(client.Password)); SqlDataReader _reader = await _insert.ExecuteReaderAsync(); while (await _reader.ReadAsync()) { client.DatosPersonales = new DatosPersonales(); client.DatosPersonales.Nombre = _reader.GetString(0); client.DatosPersonales.Apellidos = _reader.GetString(1); client.DatosPersonales.Movil = _reader.GetString(2); if (_reader.GetString(3) != null) { client.DatosPersonales.Fijo = _reader.GetString(3); } client.Password = null; return(client); } _insert.Connection.Close(); } catch (Exception) { } return(null); }