Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Contracts;
- using Contracts.NoteEntities;
- using Microsoft.AspNetCore.Identity;
- namespace Repository;
- public class RepositoryManager : IRepositoryManager
- {
- private readonly RepositoryContext _repositoryContext;
- private readonly Lazy<IBookRepository> _bookRepository;
- private readonly Lazy<IPageRepository> _pageRepository;
- private readonly Lazy<INoteEntityRepository> _noteEntityRepository;
- private readonly Lazy<IPostRepository> _postRepository;
- private readonly Lazy<ICommentRepository> _commentRepository;
- private readonly Lazy<ILikeRepository> _likeRepository;
- private readonly Lazy<IUserRelationshipRepository> _userRelationshipRepository;
- private readonly Lazy<IDisposable> _userRepository;
- public RepositoryManager(RepositoryContext repositoryContext)
- {
- _repositoryContext = repositoryContext;
- _bookRepository = new Lazy<IBookRepository>(() => new BookRepository(repositoryContext));
- _pageRepository = new Lazy<IPageRepository>(() => new PageRepository(repositoryContext));
- _noteEntityRepository = new Lazy<INoteEntityRepository>(() => new NoteEntityRepositrory(repositoryContext));
- _postRepository = new Lazy<IPostRepository>(() => new PostRepository(repositoryContext));
- _commentRepository = new Lazy<ICommentRepository>(() => new CommentRepository(repositoryContext));
- _likeRepository = new Lazy<ILikeRepository>(() => new LikeRepository(repositoryContext));
- _userRelationshipRepository = new Lazy<IUserRelationshipRepository>(() => new UserRelationshipsRepository(repositoryContext));
- }
- public IBookRepository Book => _bookRepository.Value;
- public IPageRepository Page => _pageRepository.Value;
- public INoteEntityRepository NoteEntity => _noteEntityRepository.Value;
- public IPostRepository Post => _postRepository.Value;
- public ICommentRepository Comment => _commentRepository.Value;
- public ILikeRepository Like => _likeRepository.Value;
- public IUserRelationshipRepository UserRelationship => _userRelationshipRepository.Value;
- public async Task SaveAsync() => _repositoryContext.SaveChangesAsync();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement