Guest User

Untitled

a guest
Jun 17th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. public interface ISomeUsefulName
  2. {
  3. IList<User> FetchUsers();
  4. User FetchUser(int userId);
  5. bool SaveUser(User user);
  6. bool DeleteUser(int userId);
  7. }
  8.  
  9. public interface IRepository<TYPE, KEY>{
  10. IList<TYPE> GetAll(KEY key);
  11. TYPE GetById(KEY key);
  12. void Save(TYPE obj);
  13. void Update(TYPE obj);
  14. void Delete(Key key);
  15. }
  16.  
  17. public interface IUserRepository : IRepository<User, int>
  18. {
  19. IList<User> GetAllMyFavorites(ICriteria crit);
  20. IList<Events> GetHistoryByUser(User user);
  21. }
  22.  
  23. public UserController {
  24. private _userRepository = null;
  25. private _eventsRepository = null;
  26.  
  27. public UserController(IUserRepository userRepository,
  28. IRepository<Events,int> eventsRepository)
  29. // if you are doing here just CRUD use the generic signature
  30. {
  31. _userRepository = userRepository;
  32. _eventsRepository = eventsRepository;
  33. }
  34.  
  35. public MarkItAsGoldPartener(int userId){
  36. var user = userRepository.GetById(userId);
  37. user.PartnerType = PartnerTypes.Gold;
  38. userRepository.Save(user); // the user in member name is useless
  39. eventsRepository.Save(new Event(){Message = "The user" + UserId + "is golden" });
  40. }
  41. }
  42.  
  43. public interface IUserList
  44. {
  45. IList<User> FetchUsers();
  46. }
  47.  
  48. public interface IUser
  49. {
  50. User FetchUser(int userId);
  51. }
  52.  
  53. public interface IUserStore
  54. {
  55. bool SaveUser(User user);
  56. bool DeleteUser(int userId);
  57. }
  58.  
  59. ICrud<T> { }
  60.  
  61. IStore<T> { }
Add Comment
Please, Sign In to add comment