I have a Web API in between a SQL database and a C# Winform app. The database table contains serial numbers. The Winform application issues a GET request and on the server-side, the entire list of serial numbers in that table are sorted numerically from smallest to largest.
The smallest number is put into a recursive method, which iterates through the list and generates new ones wherever there is a gap in the numerical sequence. The number of serial numbers that need to be generated is based on the input from the client-side Winform application.
Once the serial numbers are generated server-side, they are returned to the client's Winform application. Once they're happy with everything, they click a 'Print' button, which does three things: (1) Prints the serial numbers, (2) Saves the serial numbers and (3) Sends a POST request to the Web API and commits the newly generated numbers to the table.
I'm new to Web APIs, and have read a bit about throttling, but this doesn't seem to apply to what my problem entails, which is basically this:
The Winform application will be used by several people at a time (not many: two, three, four tops), but there is a chance that two clients issue the same GET request on the same table at the same time. So when one client goes to Print/Save/POST those serial numbers, the other client would not be able to do that given that most or all of those numbers would have already been committed to the database.
So basically, I'm looking for the best way of handling this problem. Maybe there's a way via the Web API to display on each Winform application who is currently using said app, displaying their IP address, and locking out other user's from generating numbers until the one client is finished with their GET/POST process? But this seems somewhat clunky and not as robust.
I'm sure there's a more elegant way of handling this, and being new to Web APIs, I'm not really sure what to search for, besides throttling, but that seems to limit the number of request issued within a certain time frame whereas my conditions require that other users not be able to issue any API calls while other users are in the middle of the GET/POST process.