Skip to content

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

jingwang315
Copy link

No description provided.

public async Task<ParkingLot> UpdateParkingLotAsync(string id, CapacityDto capacityDto)
{
ParkingLot parkingLot = await GetByIdAsync(id);
if (capacityDto.Capacity < 10 || capacityDto.Capacity < parkingLot.Capacity)
Copy link

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();
Copy link

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

@celianiu
Copy link

celianiu commented Nov 9, 2023

Good: small step commit

namespace ParkingLotApi.Exceptions
{
[Serializable]
internal class InvalidPageIndexException : Exception

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

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;

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();

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants