Reputation: 142
I want to execute 2 Actions and make them atomic. This is what I want to achieve:
public IActionResult DataUserForm()
{
return View();
}
[HttpPost]
public IActionResult Handler(data)
{
/*
Do something with data
*/
return RedirectToAction("Index");
}
DataUserForm View sends a Form to User where he can write some data. Then he is redirected to Handler, that does some business logic and redirects to Index homePage. I want to make all this Actions a transaction
There is already BeginTransaction() method in EF. But it can only be used with specific block of code and not in the methods. I also can not pass transaction as a parameter to action, because there are some problems with submit buttons and c# object
Upvotes: 0
Views: 255
Reputation: 89091
Your DbContext is a scoped service, so you have a single instance per web request.
Upvotes: 1