Skip to content

Yuhua's PR AC 1-7 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

celianiu
Copy link

@celianiu celianiu commented Nov 6, 2023

No description provided.


if ((pageIndex * pageSize) > companies.Count())
{
return StatusCode(StatusCodes.Status204NoContent);

Choose a reason for hiding this comment

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

well: nice to use 204 for no found related data
suggestion: also return empty list to client

{
return StatusCode(StatusCodes.Status204NoContent);
}
var ressultCompanies = companies.Skip((int)((pageIndex - 1) * pageSize)).Take((int)pageSize).ToList();

Choose a reason for hiding this comment

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

well: nice to use Skip Take
sugesstion: extract (pageIndex-1) * pageSize to a temp variable

var company = companies.Find(company => company.Id.Equals(id));
if (company == null)
{
return NotFound();

Choose a reason for hiding this comment

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

well: nice to return 404 if not found company

PUT https://{{hostname}}:{{port}}/api/Companies/{companyID}/employee/{employeeId}
Content-Type: application/json; charset=utf-8

Choose a reason for hiding this comment

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

suggestion: add request body for update company

@@ -20,6 +23,75 @@ public ActionResult<Company> Create(CreateCompanyRequest request)
return StatusCode(StatusCodes.Status201Created, companyCreated);
}

[HttpGet]

Choose a reason for hiding this comment

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

good code logic

}

[Fact]
public async Task Should_return_companies_with_status_200_when_get_company_given_page_and_index()

Choose a reason for hiding this comment

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

Suggest add one test case(such as pageIndex = -1 & pageSize = -2)

Choose a reason for hiding this comment

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

maybe this case make code logic success, but not satisfied

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.

3 participants