Advertisement
Guest User

Untitled

a guest
Feb 1st, 2024
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. using Contracts;
  2. using Contracts.NoteEntities;
  3. using Microsoft.AspNetCore.Identity;
  4.  
  5. namespace Repository;
  6.  
  7. public class RepositoryManager : IRepositoryManager
  8. {
  9. private readonly RepositoryContext _repositoryContext;
  10. private readonly Lazy<IBookRepository> _bookRepository;
  11. private readonly Lazy<IPageRepository> _pageRepository;
  12. private readonly Lazy<INoteEntityRepository> _noteEntityRepository;
  13. private readonly Lazy<IPostRepository> _postRepository;
  14. private readonly Lazy<ICommentRepository> _commentRepository;
  15. private readonly Lazy<ILikeRepository> _likeRepository;
  16. private readonly Lazy<IUserRelationshipRepository> _userRelationshipRepository;
  17. private readonly Lazy<IDisposable> _userRepository;
  18. public RepositoryManager(RepositoryContext repositoryContext)
  19. {
  20. _repositoryContext = repositoryContext;
  21. _bookRepository = new Lazy<IBookRepository>(() => new BookRepository(repositoryContext));
  22. _pageRepository = new Lazy<IPageRepository>(() => new PageRepository(repositoryContext));
  23. _noteEntityRepository = new Lazy<INoteEntityRepository>(() => new NoteEntityRepositrory(repositoryContext));
  24. _postRepository = new Lazy<IPostRepository>(() => new PostRepository(repositoryContext));
  25. _commentRepository = new Lazy<ICommentRepository>(() => new CommentRepository(repositoryContext));
  26. _likeRepository = new Lazy<ILikeRepository>(() => new LikeRepository(repositoryContext));
  27. _userRelationshipRepository = new Lazy<IUserRelationshipRepository>(() => new UserRelationshipsRepository(repositoryContext));
  28. }
  29.  
  30. public IBookRepository Book => _bookRepository.Value;
  31. public IPageRepository Page => _pageRepository.Value;
  32. public INoteEntityRepository NoteEntity => _noteEntityRepository.Value;
  33. public IPostRepository Post => _postRepository.Value;
  34. public ICommentRepository Comment => _commentRepository.Value;
  35. public ILikeRepository Like => _likeRepository.Value;
  36. public IUserRelationshipRepository UserRelationship => _userRelationshipRepository.Value;
  37. public async Task SaveAsync() => _repositoryContext.SaveChangesAsync();
  38.  
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement