prinx / dotnet-shopping-cart Goto Github PK
View Code? Open in Web Editor NEWSample Shopping Cart API using .NET Core
License: MIT License
Sample Shopping Cart API using .NET Core
License: MIT License
Try to make you response the same format:
ie:
{
"success": true,
"message": "Item added to cart", //this could be nice error messages in case of failure
"data": {
.....
}
}
Also avoid using SingleOrDefault, do a little research about FindAsync and FirstOrDefaultAsync and use the one that makes more sense
Sir Prince,
I must say you have done very well so far.
The hope is that you will pick quickly when given the chance and assistance.
Try to fix these few issues for us in the meantime:
If you can push your changes to a dev branch and create a PR it will make review easier.
Any code especially those that have external dependency such as database... have the potential to throw an exception. Please try catch the exceptions in all such method.
ILogger can not be resolved in User and Product controllers and that is breaking your code please check it
https://stackoverflow.com/questions/52921966/unable-to-resolve-ilogger-from-microsoft-extensions-logging
Read the question well
You are not validating user input that is breaking your code - try to create and or update a product without passing the name and see.
You will notice the code breaks on the create without any exception handling and the update set the product name to null which should not be allowed.
When I tried to delete a product with an id that does not exist I get this
{
"status": 201,
"success": true,
"message": "Product created successfully.",
"data": null
}
With response code 404
When I pass a phoneNumber that is not string the code breaks please validate it and return a nice response and again handle exceptions
CartItemController line 110 is not needed
Avoid doing this
//_db.Entry(cartItem).State = EntityState.Added;
/api/CartItems/user/{id}
This endpoint is not returning accurate data
Finally check the assignment well and make the filters on Cart conform to the requirement
Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.