using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Contracts; namespace Repository { public sealed class RepositoryManager : IRepositoryManager { private readonly RepositoryContext _repositoryContext; private readonly Lazy _companyRepository; private readonly Lazy _employeeRepository; public RepositoryManager(RepositoryContext repositoryContext) { _repositoryContext = repositoryContext; _companyRepository = new Lazy(() => new CompanyRepository(repositoryContext)); _employeeRepository = new Lazy(() => new EmployeeRepository(repositoryContext)); } public ICompanyRepository Company => _companyRepository.Value; public IEmployeeRepository Employee => _employeeRepository.Value; public void Save() => _repositoryContext.SaveChanges(); } }