public Product GetProductById(int id) { try { using (var connection = new SqlConnection(_connectionString)) { var commandText = "SELECT * FROM Products WHERE Id = @Id"; var command = new SqlCommand(commandText, connection); command.Parameters.AddWithValue("@Id", id); connection.Open(); using (var reader = command.ExecuteReader()) { if (!reader.HasRows) { return(null); } return(ProviderUtility.DataReaderMapToObject <Product>(reader)); } } } catch (Exception) { throw; } }
public UserCredential GetUserCredentialByRefreshToken(string token) { try { using (var connection = new SqlConnection(_connectionString)) { var command = new SqlCommand(UserStoredProcedures.GetUserCredentialByRefreshToken, connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@RefreshToken", token); connection.Open(); using (var reader = command.ExecuteReader()) { if (!reader.HasRows) { return(null); } return(ProviderUtility.DataReaderMapToObject <UserCredential>(reader)); } } } catch (Exception) { throw; } }
public Product GetFeaturedProduct() { try { using (var connection = new SqlConnection(_connectionString)) { var command = new SqlCommand(ProductStoredProcedures.FeaturedProduct, connection); command.CommandType = CommandType.StoredProcedure; connection.Open(); using (var reader = command.ExecuteReader()) { if (!reader.HasRows) { return(null); } return(ProviderUtility.DataReaderMapToObject <Product>(reader)); } } } catch (Exception) { throw; } }