Codit / practical-api-guidelines

Practical guidelines for building & designing APIs with .NET.
MIT License
16 stars 5 forks source link

Create a dedicated model for creating new players #48

Closed fgheysels closed 5 years ago

fgheysels commented 5 years ago

Changed the CreatePlayer operation to use a dedicated model instead of the Player entity model.

A new NewPlayerDto model has been introduced that defines the minimal required properties that are necessary to create a new Player. (PlayerDto is not used since we do not want to specify a PlayerId).

When creating a new Player, we also check if there exists a Team for the specified TeamId. If not, a BadRequest is returned.

fgheysels commented 5 years ago

I've seen in the code that we have a ValidateModelAttribute action-filter. However, since all our controllers are decorated with the ApiController attribute, I believe that the ValidateModelAttribute filter is no longer required.

samneirinck commented 5 years ago

I've seen in the code that we have a ValidateModelAttribute action-filter. However, since all our controllers are decorated with the ApiController attribute, I believe that the ValidateModelAttribute filter is no longer required.

Yes, would be good to remove it in a seperate PR.