Created
March 3, 2013 20:07
-
-
Save erikdietrich/5078046 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 SomeClass | |
{ | |
private readonly List<Customer> _customers = new List<Customer>(); | |
public void AddCustomerForModelIfValid(CustomerModel modelOfCustomer) | |
{ | |
if (IsModelValidForAdding(modelOfCustomer)) | |
AddCustomerForModel(modelOfCustomer); | |
} | |
private bool IsModelValidForAdding(CustomerModel modelOfCustomer) | |
{ | |
return modelOfCustomer.IsActive && !_customers.Any(c => c.Name == modelOfCustomer.Name); | |
} | |
private void AddCustomerForModel(CustomerModel modelOfCustomer) | |
{ | |
var customerBasedOnModel = new Customer() | |
{ | |
Name = modelOfCustomer.Name | |
}; | |
_customers.Add(customerBasedOnModel); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment