private async Task SendEmailForAdministratorAsync() { using var scope = _scopeFactory.CreateScope(); var adminRepository = scope.ServiceProvider.GetRequiredService <IAdministratorRepository>(); var bookLoansRepository = scope.ServiceProvider.GetRequiredService <IBookLoanRepository>(); var admins = await adminRepository.GetAll(); var bookLoans = await bookLoansRepository.GetBookLoansDelayed(); if (bookLoans.Any()) { await _emailServices.SendReminderAdmEmail(admins, bookLoans); } }