public Customer FindBy(Guid id) { CustomerProxy customer = new CustomerProxy(); customer.OrderRepo = _repo; return(customer); }
public Customer FindBy(Guid id) { Customer customer = new CustomerProxy(); // Code to connect to the database and retrieve a customer… var query = "SELECT Name FROM Customer WHERE Id = @Id"; var conn = new SqlConnection(SQL_CONNECTION); var command = new SqlCommand(query, conn); command.Parameters.AddWithValue("@Id", id); conn.Open(); try { var reader = command.ExecuteReader(); if(reader.HasRows) { reader.Read(); customer.Id = id; customer.Name = reader.GetString(0); } } finally { conn.Close(); } ((CustomerProxy)customer).OrderRepository = _orderRepository; return customer; }
public Customer FindBy(Guid id) { Customer customer = new CustomerProxy(); // Code to connect to the database and retrieve a customer ((CustomerProxy)customer).OrderRepository = _orderRepository; return(customer); }