public class Customer
{
public string Id { get; set; }
public string ContactName { get; set; }
public string CompanyName { get; set; }
}
public interface ICustomerDataAccess
Customer Insert(string id, string contactName, string companyName);
List<Customer> GetAllCustomer();
public class CustomerDataAccess : ICustomerDataAccess
public class CustomerLogic: ICustomerLogicLayer
ICustomerDataAccess _dataLayer;
public CustomerLogic(ICustomerDataAccess dataLayer)
_dataLayer = dataLayer;
public Customer Create(string customerName, string companyName)
var id = Guid.NewGuid().ToString("N").Substring(0, 5).ToUpper();
return _dataLayer.Insert(id, customerName, companyName);
public List<Customer> GetAllCustomers()
return _dataLayer.GetAllCustomer().OrderBy(cust => cust.ContactName).ToList();
public interface ICustomerLogicLayer
Customer Create(string customerName, string companyName);
List<Customer> GetAllCustomers();
var logic = new LogicLayer.CustomerLogic(new DataLayer.CustomerDataAccess());