public string NotifyBookDeadline() { string message = ""; db.Configuration.ProxyCreationEnabled = false; var dateTime = DateTime.UtcNow.AddDays(-1); var getBookLogs = db.BookLogs.Where(b => b.Return == false).Where(b => b.Deadline >= dateTime && b.Deadline <= DateTime.UtcNow).ToList(); foreach (var log in getBookLogs) { message = message + SMTP.SendNotification(log.Id); } return(message); }