I am beginner in Web Development. I need a help designing .net 6 web api project.
I have web application , which has front end with HTML-JS-CSS and back end with .net 6 web api.
I have set of services
- login API
- Pre_Processing Api
- Transfer API
I have added session in project.
front end calls "pre_processing api", after which it return large set of objects to front end. For each such object the third "transfer api" is been called.
I have injected dbcontext using entity framework.
Now I need to add credit mechanism for allowing and disallowing transferring activity which is based on platform basis (having multiple users on one system).
The business logic is shared in "pre_processing" and "transfer api". I need to lock/deduct a credit value from database table for user , on how many transfers he is going to make in advance. which should reflect to other user.
If I lock/deduct credit in database table in pre_processing(controller) api. I need to rollback the locking of credits [the action of pre_processing api] on results(success /failure) of "transfer api".
storing everything information in session variable is making logic complex and inaccurate.
How could i go further?
I am not able to inject a dbcontext per user session?. Is there any library one can use to implement credit based transactions?**
I tried with storing transaction information in session. The dbcontext now disposes with each http request. But i am expecting more robust and consistent approach to solve this problem.