Skip to content

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

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

Yuhua's PR #3

wants to merge 15 commits into from

Conversation

celianiu
Copy link

@celianiu celianiu commented Nov 8, 2023

No description provided.

[HttpGet("{id}")]
public async Task<ActionResult<ParkingLotDto>> GetParkingLost(string id)
{
return StatusCode(StatusCodes.Status200OK, await parkingService.GetParkLot(id));

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)

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)

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

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

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)

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

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

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;

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

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