-
Notifications
You must be signed in to change notification settings - Fork 3
ParkingLotApiByWangJing #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
base: main
Are you sure you want to change the base?
Conversation
public async Task<ParkingLot> UpdateParkingLotAsync(string id, CapacityDto capacityDto) | ||
{ | ||
ParkingLot parkingLot = await GetByIdAsync(id); | ||
if (capacityDto.Capacity < 10 || capacityDto.Capacity < parkingLot.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.
Good: very 严谨!
{ | ||
throw new InvalidPageIndexException(); | ||
} | ||
return parkingLots.Skip(pagesToBeSkip).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.
Improve: Better get by page in repository instead of getAll and filter in service
Good: small step commit |
namespace ParkingLotApi.Exceptions | ||
{ | ||
[Serializable] | ||
internal class InvalidPageIndexException : 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 define customized exception
|
||
namespace ParkingLotApi.Filters | ||
{ | ||
public class InvalidPageIndexExceptionFilter : IActionFilter, IOrderedFilter |
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 add more than one exception filter
{ | ||
public class InvalidPageIndexExceptionFilter : IActionFilter, IOrderedFilter | ||
{ | ||
public int Order => 2; |
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 set different order for each filter
|
||
public async Task<List<ParkingLot>> GetInPageAsync(int pageIndex) | ||
{ | ||
List<ParkingLot> parkingLots = await GetAsync(); |
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 code will return all data, might cause issue if there is huge amount of data in db
No description provided.