-
Notifications
You must be signed in to change notification settings - Fork 4
Shuhan Jin #5
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?
Shuhan Jin #5
Conversation
if (pageSize != null && pageIndex != null) | ||
{ | ||
var startIndex = (pageIndex - 1) * pageSize; | ||
var companiesPage = companies.Skip((int)startIndex).Take((int)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.
WangKe:
Great using of the Linq syntax 👍
//employee.Id = Guid.NewGuid().ToString(); | ||
company.Employees.Add(employee); | ||
|
||
return Ok(employee); |
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.
As we add new employee here, maybe [return Created(employee)] could be better
WangKe:
Improves: |
Content-Type: application/json; charset=utf-8 | ||
|
||
Company: |
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: not need this json for company, we find related company by companyID in the URL
### Case1: success, 204 no content | ||
### Case2: 404 Company NOT Found | ||
### Case3: 404 emloyee NOT Found |
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 be improved: we also need to design api for AC 8-10
var company = companies.Find(c => c.Id == companyId); | ||
if (company == null) | ||
{ | ||
return NotFound(); |
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.
well: use 404 if company can not be found👍
if (pageSize != null && pageIndex != null) | ||
{ | ||
var startIndex = (pageIndex - 1) * pageSize; | ||
var companiesPage = companies.Skip((int)startIndex).Take((int)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.
well: nice to use Skip and Take
No description provided.