1.Becasue web application project need to check the objects ownership of current users, we need to check every model, every controller method, even use at view. We should obey the DRY principle.
-
only one location get current user, you can change logic any time not need touch others codes.
-
WorkContext including current user / Language / Currency / Vendor / TaxDisplay / IsAdmin etc.
Solution: create an IWorkContext and DI it. WorkContext class implements the interface IWorkContext, and register it on container, then we can use it on controller , services , view etc.
refernce URL:
ASP.NET best practice for checking model's objects ownership
enjoin Coding!
Aucun commentaire:
Enregistrer un commentaire