Last active
December 14, 2015 04:39
-
-
Save GuyHarwood/5029946 to your computer and use it in GitHub Desktop.
I am sick of seeing code like this...
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
//the 'domain/service' layer... | |
public class ContactService | |
{ | |
public ContactService(IContactRepository contactRepository) | |
{ | |
_contactRepository = contactRepository; | |
} | |
public Contact GetContact(int id) | |
{ | |
var contact = _contactRepository.FindById(id); | |
return contact; | |
} | |
} | |
//the 'data' layer... | |
public class ContactRepository : IContactRepository | |
{ | |
public ContactRepository(DataContext db) | |
{ | |
_db = db; | |
} | |
public Contact FindById(int id) | |
{ | |
var qry = from c in _db.Contacts | |
where c.ContactId == id | |
&& c.IsDeleted == false | |
select c; | |
return qry.FirstOrDefault(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment