I'm developing an Asp.Net WebApi Application. Now I'm trying to implement state machine in my application using Stateless 3.0 library.
1. Model Class
Model will have a State property, and state change logic in the model class. Once State is changed the model will be updated in client side, and an update request will be sent to server to make changes in Database.
2. WebApi Controller
Model will have a State property, and state change logic in the controller class. A WebApi action called ChangeState() will be called from client side, so the model will be updated in the serverside and saved into database.
PS. I'm using Odata V4.
Question 1:
What is the best method to follow? Any other suggestion? (I'm new to Stateless)
Question 2:
Can I implement state machine logic in a Static class? Is that a good idea?
Question 3:
How can I give custom state error messages to the end user?
Ex: Invoice cannot be 'Authorized' when it's in 'Cancelled' state.
Highly appreciated if anyone can provide a sample code.