Attendance App: Real-Time Use of DI Lifetimes
Attendance App: Real-Time Use of DI Lifetimes App Features: Students check-in/out Admin manages students Log every operation (via Singleton) Attendance processed per request (Scoped) Utility services like OTP, Email (Transient) 1. Service Lifetimes in Real Context Service Lifetime Why? ILoggingService Singleton One instance, logs everything app-wide AttendanceService Scoped Scoped per HTTP request (to avoid stale state) EmailNotificationService Transient Lightweight utility, recreated each time OtpGeneratorService Transient Stateless, new per use DbContext (EF Core) Scoped Scoped per request to manage transactions safely 2. Interface Definitions public interface ILoggingService { void Log(string m...