Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created October 27, 2012 16:12
Show Gist options
  • Save jasongorman/3965195 to your computer and use it in GitHub Desktop.
Save jasongorman/3965195 to your computer and use it in GitHub Desktop.
public class CustomerServices
{
private readonly IDataRepository dataRepository;
public CustomerServices(IDataRepository repository)
{
dataRepository = repository;
}
public string FetchCustomerXmlById(int customerId)
{
Customer customer = dataRepository.GetCustomer(customerId);
string xml = "<Error>Customer not found</Error>";
if(customer != null)
{
xml = "<Customer id='" + customerId + "'>" + customer.Name + "</Customer>";
}
return xml;
}
public string FindCustomersXmlByName(string nameToMatch)
{
IList<Customer> matches = dataRepository.FindCustomers(nameToMatch);
string xml = "<Matches count='" + matches.Count + "'>";
foreach(Customer customer in matches){
xml += "<Customer id='" + customer.Id + "'>" + customer.Name + "</Customer>";
}
xml += "</Matches>";
return xml;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment