Created a ASP.NET Core MVC app with the basic CRUD and sort funtionality. Apis have been exposed under the routes and port[8081] shared as in question sheet.
- .Net 6
- SQL Server Express 2019 (This has been commented out for testing purpose)
- InMemory EFCore - version 6 (This will be working, it has been added so we don't require DB setup to test APIS/MVC app)
- Visual Studio 2022
- Postman
-
Get All - GET - https://localhost:{{port}}/api/Inventory
-
GetByItem - GET - https://localhost:{{port}}/api/Inventory/{itemName}
-
CreateOrUpdate - POST - https://localhost:{{port}}/api/Inventory
-
Update - PUT - https://localhost:{{port}}/api/Inventory/{itemName}
-
Delete - DELETE - https://localhost:{{port}}/api/Inventory/{itemName}
-
Sort - GET - https://localhost:{{port}}/api/Inventory/values?sortBy=quantity_desc&returnVal=all
The sortBy and returnVal query strings can have multiple values -
sortBy-
- sortBy = quantity_desc - Order by quantity desc
- sortBy = quantity - Order by quantity asc
- sortBy = Date - Order by created on desc
- sortBy = date_desc - Order by created on desc
- sortBy = name_desc - Order by name desc
- sortBy = name - Order by name asc
returnVal-
- returnVal = 1 - Return Top 1 based on the sortBy specified (Highest/Lowest)
- returnVal = all -Returns all items in the specicifed order
This is the Index page of MVC app.
This is an example of Sort APi-
- Concurrency conflicts - I have handled concurrency conflict using RowVersion. If we have opened the same item in two tabs and one user is updating the quantity in one tab, and the other user tries to update in the second tab, it will throw a ModelState Error- stating that value has been modified by the user and it shows the current value under the quantity field.
Also throught API Request, we can see the following error-

- Included LastUpdatedOn field so that we can track the update history.
- Included Unit test (xUnit) for controllers
Note:- RowVersion functionality will only work when connected to sql server express.


