Skip to content

Conversation

@JJHH17
Copy link

@JJHH17 JJHH17 commented Oct 9, 2025

This project:

Copy link

@chrisjamiecarter chrisjamiecarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JJHH17 👋,

Excellent work on your Ecommerce API project submission 🎉!

I have performed a peer review. Review/ignore any comments as you wish.


💪 Well done on a great project. I liked your use of pagination and responses in the API, and tried to give tips on how you could improve this. A bit of polish and latest code styles is needed to bring this project up to modern standards, but overall it is a well thought out and structured project.


🟢 Requirements

⭐ You have fulfilled all of the project requirements!


I will go ahead and mark as approved, keep up the excellent work on the next projects! 😊

Best regards,
@chrisjamiecarter 👍

Comment on lines +5 to +6
namespace ECommerceApi.JJHH17.Controllers
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Namespaces

💡 As per the academy's code-conventions, use file-scoped namespaces.

➡️ From C# 10, we are able to remove the block/braces and save on level of indentation, optimising space and improving readability.

Suggested change
namespace ECommerceApi.JJHH17.Controllers
{
namespace ECommerceApi.JJHH17.Controllers;

if (pagination.PageNumber < 1) pagination.PageNumber = 1;
if (pagination.PageSize < 1) pagination.PageSize = 10;

var allCategories = _categoryService.GetAllCategories();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Inefficient

💡 Great job implementing pagination. But ideally you would want to pass the pagination responsibility down to your db context.

💭 Say your database has 10m rows. Currently your api would get 10m rows from the database, hold in memory and then filter down to the first 10 rows (as an example). Imagine the cost, time, and resource implications of this. If using a cloud database provider you would quickly run out of money.

🔧 Instead you should use the database to only get the 10 rows you need, only hold 10 rows in memory, etc, etc.

Comment on lines +42 to +44
if (result == null) { return NotFound(); }

return Ok(result);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Simplify

💡 Use the ternary conditional operator. condition ? consequent : alternative

💭 e.g. IfThisIsTrue ? DoThis : ElseDoThis

Suggested change
if (result == null) { return NotFound(); }
return Ok(result);
return result is null
? NotFound()
: Ok(result);

[HttpPost]
public ActionResult<CreateCategoryDto> CreateCategory(CreateCategoryDto category)
{
return Ok(_categoryService.CreateCategory(category));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 REST

💡 Post requests should return a 201 Created response to indicate successful creation and the location of the created resource.

Comment on lines +5 to +6
namespace ECommerceApi.JJHH17.Controllers
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace ECommerceApi.JJHH17.Controllers
{
namespace ECommerceApi.JJHH17.Controllers;

.Single();
}

public List<GetProductsDto> GetAllProducts()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Pagination

Comment on lines +5 to +6
namespace ECommerceApi.JJHH17.Services
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace ECommerceApi.JJHH17.Services
{
namespace ECommerceApi.JJHH17.Services;

_dbContext = dbContext;
}

public List<SaleWithProductsDto> GetAllSales()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Pagination

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Redundant Code

❗ Remove.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 README Location

💡 Remember, you are writing a README for your project submission, not the code reviews repository, this file should be in your project submission folder.

📁 CodeReviews.Console.EcommerceApi
 ┣ 📄 .codacy.yml
 ┣ 📄 .gitignore
 ┣ 📁 EcommerceApi.JJHH17
 ┃  ┗ 📄 EcommerceApi.sln
 ┃  ┗ 📄 README.md ⬅️ Goes here!
 ┃  ┗ 📁 EcommerceApi.Api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants