Created
December 31, 2010 08:25
-
-
Save juristr/760856 to your computer and use it in GitHub Desktop.
Taken from a #smellycode post, just to demonstrate the usage fo gist in code reviews
This file contains hidden or 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 Account ReadCompleteAccountByADUsernameAndServiceUID(string adUsername, string serviceInstanceUID) | |
{ | |
IList<Address> addresses; | |
IList<Contact> contacts; | |
//Attention, directly instantiating an object within the method may potentially create | |
//problems when doing testing 'cause its dependency cannot be mocked out. | |
MasterDataBL masterDataBL = new MasterDataBL(); | |
Account result = AccoDao.ReadCompleteAccountByADUsernameAndServiceUID(adUsername, serviceInstanceUID, ConnectionString.Master, out addresses, out contacts); | |
result.PhoneNumber = contacts.Where(x => x.ContactType.Id == masterDataBL.GetCachedContactTypeByUid(ContactType.WellKnownUid.PHONE).Id).FirstOrDefault(); | |
result.MobilePhone = contacts.Where(x => x.ContactType.Id == masterDataBL.GetCachedContactTypeByUid(ContactType.WellKnownUid.MOBILE).Id).FirstOrDefault(); | |
result.Residence = addresses.Where(x => x.AddressTypeId == masterDataBL.GetCachedAddressTypeByUid(AddressType.WellKnownUid.RESIDENCE).Id).FirstOrDefault(); | |
result.Domicile = addresses.Where(x => x.AddressTypeId == masterDataBL.GetCachedAddressTypeByUid(AddressType.WellKnownUid.DOMICILE).Id).FirstOrDefault(); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feel free to make your edits here or add any comments. Note, this is just an example taken from one of my #smellycode posts (http://blog.js-development.com/2010/12/smelly-code-direct-object-instantiation.html)