Last active
August 2, 2020 23:28
-
-
Save carloszan/800d05a38e65077930a2f403781861c7 to your computer and use it in GitHub Desktop.
Introdução a padrões de projeto
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 interface IDatabase<TEntity> | |
{ | |
Task SaveAsync(TEntity entity); | |
Task<TEntity> Get(Guid id); | |
Task<ICollection<TEntity>> GetAll(); | |
Task Delete(Guid id); | |
Task<TEntity> Update(TEntity entity); | |
} |
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 class UserMongoDb : IDatabase<User> | |
{ | |
Task SaveAsync(TEntity entity) | |
{ | |
... | |
} | |
Task<TEntity> Get(Guid id) | |
{ | |
... | |
} | |
Task<ICollection<TEntity>> GetAll() | |
{ | |
... | |
} | |
Task Delete(Guid id) | |
{ | |
... | |
} | |
Task<TEntity> Update(TEntity entity) | |
{ | |
... | |
} | |
} |
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 class UserService | |
{ | |
private readonly IDatabase<User> _database; | |
public UserService( | |
IDatabase<User> database | |
) | |
{ | |
_database = database; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment