I have bunch of action-methods that need to verify the ownership of the orderId
passed to the action something like:
public ActionResult CancelOrder(int orderId) {
If (!MyDatabase.VerifyOwnership(orderId, User.Identity.Name) return View("You are an imposter!");
// ...
}
What's an easy way to verify orderId
belongs to User.IdentityName
without having to copy/paste same lines over and over?
I have tried ActionFilterAttribute
but it doesn't have access to the context (MyDatabase
object for example). What's a good way to handle this?