I am creating a REST API so I am creating my controller. I have entity that is:
public class User
{
public int Id { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public int Age { get; set; }
public string PersonalInformation { get; set; }
}
In my front-end I have 2 views that requires two different models of the User.
An admin can check the personal information of the user and he needs to see all the information except of the password.
A user con modify all his information, so he will need to see all his information.
I this case, I will need two different models to send to the frontend, one with the password and one without it.
To access this information my controller will have a method:
[HttpGet("{id}")]
public IActionResult Get(int id)
{
....
}
At this point comes my question, because I have same method to return two different models (in the future may be more). Investigation on Web Api Design, I read that the keyword to access may no be verbs. One method url will be /users/1, but the other must be different and here comes my problem.
Thanks!
Aucun commentaire:
Enregistrer un commentaire