Skip to content

Homework from Xinwei Lu #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

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

Conversation

XDL27
Copy link

@XDL27 XDL27 commented Nov 8, 2023

No description provided.

Copy link

@JCLTW JCLTW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一些反馈

[HttpPut("{id}")]
public async Task<ActionResult> UpdateCapacityAsync(string id, CapacityDto capacityDto)
{
if (capacityDto.Capacity < 10)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以定义常量


public int Capacity { get; set; }

internal ParkingLot ToEntity()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

定义DTO很好


namespace ParkingLotApi.Repositories;

public interface IParkingLotsRepository
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

定义接口很好


public class ParkingLotsRepository : IParkingLotsRepository
{
private const int PageSize = 15;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

定义常量很好,常量风格符合C#规范


public async Task<List<ParkingLot>> GetParkingLotsAsync(int pageNumber)
{
return await _parkingLotColelction.Find(_ => true).Skip((pageNumber - 1) * PageSize).Limit(PageSize).ToListAsync();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

很好,没在内存中分页


public async Task<ParkingLot> AddParkingLotAsyncAsync(ParkingLotsDto parkingLotDto)
{
if (parkingLotDto.Capacity < 10)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该定义常量


namespace ParkingLotApiTest.Controller;

public class WeatherForecastControllerTest :TestBase
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以删掉了

this._parkingLotsRepository = parkingLotsRepository;
}

public async Task<ParkingLot> AddParkingLotAsyncAsync(ParkingLotsDto parkingLotDto)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name field is unique, need to check

throw new ParkingLotNotFoundException();
}

return _parkingLotColelction.Find(lot => lot.Id.Equals(id)).FirstOrDefault();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe Find(lot => lot.Id.Equals(id)) can change to .Find(filter)

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