-
Notifications
You must be signed in to change notification settings - Fork 3
WangKe's HW #4
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: main
Are you sure you want to change the base?
WangKe's HW #4
Conversation
…he parking lot with lessThan10 capacity.
…nvalidCapacity exception.
…and ParkingLotsController.
…sService and ParkingLotsController.
well
|
public async Task<ActionResult<List<ParkingLotEntity>>> GetParkingLotById(string id) | ||
{ | ||
var parkingLot = await _parkingLotsService.GetByIdAsync(id); | ||
if (parkingLot == null) |
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: avoid return null from method, since null is hard to understand. here we can throw exception from service
} | ||
|
||
[HttpPut("{id}")] | ||
public async Task<ActionResult<ParkingLotEntity>> UpdateCapacityAsync(string id, [FromBody] int capacity) |
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 class for request body instead of int
var updatedParkingLot = await _parkingLotsService.UpdateCapacity(id, capacity); | ||
if (updatedParkingLot == 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.
suggestion: this can also be handled in global exception handler
No description provided.