-
Notifications
You must be signed in to change notification settings - Fork 3
Yuhua's PR #3
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?
Yuhua's PR #3
Conversation
[HttpGet("{id}")] | ||
public async Task<ActionResult<ParkingLotDto>> GetParkingLost(string id) | ||
{ | ||
return StatusCode(StatusCodes.Status200OK, await parkingService.GetParkLot(id)); |
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: should return 404 not found for non-existing ids
context.Result = new BadRequestResult(); | ||
context.ExceptionHandled = true; | ||
} | ||
if (context.Exception is FormatException) |
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: Good use of filter for format exception handling
[HttpGet] | ||
public async Task<ActionResult> GetParkingLosts(int pageIndex = 0) | ||
{ | ||
if (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.
WangKe: good consideration for the pageIndex invalidation
|
||
if (parkingLotEntity == null) | ||
{ | ||
throw new DuplicateNameException(); |
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: good consideration for the name duplication exception
|
||
namespace ParkingLotApi.Exceptions | ||
{ | ||
public class DuplicateNameException : Exception |
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 customized exception to present business issue
{ | ||
int IOrderedFilter.Order => int.MaxValue - 10; | ||
|
||
public void OnActionExecuted(ActionExecutedContext context) |
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 handle more than one exception
@@ -0,0 +1,9 @@ | |||
namespace ParkingLotApi.Dtos | |||
{ | |||
public class ParkingLotRequestDto |
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 define dto for request
using ParkingLotApi.Dtos; | ||
using ParkingLotApi.Models; | ||
|
||
namespace ParkingLotApi.Utils |
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: the class can be moved to Services, since it's only use in service
|
||
public async Task<List<ParkingLotDto>?> GetParkLots(int pageIndex) | ||
{ | ||
int skipItems = (pageIndex - 1) * 15; |
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: 15 can be extract as a constant
No description provided.