-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
Conversation
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.
一些反馈
[HttpPut("{id}")] | ||
public async Task<ActionResult> UpdateCapacityAsync(string id, CapacityDto capacityDto) | ||
{ | ||
if (capacityDto.Capacity < 10) |
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.
可以定义常量
|
||
public int Capacity { get; set; } | ||
|
||
internal ParkingLot ToEntity() |
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.
定义DTO很好
|
||
namespace ParkingLotApi.Repositories; | ||
|
||
public interface IParkingLotsRepository |
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.
定义接口很好
|
||
public class ParkingLotsRepository : IParkingLotsRepository | ||
{ | ||
private const int PageSize = 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.
定义常量很好,常量风格符合C#规范
|
||
public async Task<List<ParkingLot>> GetParkingLotsAsync(int pageNumber) | ||
{ | ||
return await _parkingLotColelction.Find(_ => true).Skip((pageNumber - 1) * PageSize).Limit(PageSize).ToListAsync(); |
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.
很好,没在内存中分页
|
||
public async Task<ParkingLot> AddParkingLotAsyncAsync(ParkingLotsDto parkingLotDto) | ||
{ | ||
if (parkingLotDto.Capacity < 10) |
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.
应该定义常量
|
||
namespace ParkingLotApiTest.Controller; | ||
|
||
public class WeatherForecastControllerTest :TestBase |
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.
可以删掉了
this._parkingLotsRepository = parkingLotsRepository; | ||
} | ||
|
||
public async Task<ParkingLot> AddParkingLotAsyncAsync(ParkingLotsDto parkingLotDto) |
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.
the name field is unique, need to check
throw new ParkingLotNotFoundException(); | ||
} | ||
|
||
return _parkingLotColelction.Find(lot => lot.Id.Equals(id)).FirstOrDefault(); |
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.
maybe Find(lot => lot.Id.Equals(id)) can change to .Find(filter)
No description provided.