-
Notifications
You must be signed in to change notification settings - Fork 4
Kailin company api #2
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
base: master
Are you sure you want to change the base?
Conversation
{ | ||
// Given | ||
Company companyGiven = new Company("slb"); | ||
HttpResponseMessage httpResponseMessage = await httpClient.PostAsJsonAsync("/api/companies",companyGiven); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good: Use one httpResponseMessage to handle all httpResponses. easy to read!👍
{ | ||
// Given | ||
await ClearDataAsync(); | ||
Company companyGiven = new Company("slb"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To Improve: Better use CreateCompanyRequest
and CreateEmployeeRequest
since FE doesn't provide ID
|
||
## AC9 Update Employee | ||
PUT https://{{hostname}}:{{port}}/api/companies/{companyId}/employees/{employeeId} | ||
|
There was a problem hiding this comment.
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 PUT
## DELETE /api/companies/companyID/employees/{employeeId} | ||
|
||
## AC6 Create Employee API | ||
PUT https://{{hostname}}:{{port}}/api/companies/{companyId}/employees |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: use POST instead of PUT to create resource
} | ||
|
||
var startIndex = (pageIndex - 1) * pageSize; | ||
var pagedCompanies = companies.Skip(startIndex).Take(pageSize).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 nice to use Skip Take
var company = companies.Find(c => c.Id == companyId); | ||
if (company is null) | ||
{ | ||
return BadRequest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: return 404 if the company can not be found
[HttpGet] | ||
public ActionResult<List<Company>> GetAllByIndex([FromQuery] int pageSize = 0, [FromQuery] int pageIndex = 1) | ||
{ | ||
if (pageSize <= 0 || pageIndex <= 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good: Give a init pageSize and pageIndex value. Stick with the rules!🤩
Good: Smalls step & clear code logic easy to read; |
No description provided.