Created
October 27, 2012 16:12
-
-
Save jasongorman/3965195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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