Что такое веб-API ASP.NET?C#

Место общения программистов C#
Гость
Что такое веб-API ASP.NET?

Сообщение Гость »


I saw a wrong explanation in an explanation video, but it was explained correctly in the video.
This is the code:

Код: Выделить всё

public User Put([FromBody] User user)
{
var editedUser = _users.FirstOrDefault(x => x.Id == user.Id)
editedUser.Firstname = user.Firstname;
editedUser.Lastname = user.Lastname;

return to user;
}
This was an API video. First, he defined fake data as using the bogus library. He created the model class , so there is nothing wrong with the model. But then he wrote the put method as above and the data was updated. Isn't this code wrong?


Источник: https://stackoverflow.com/questions/781 ... eb-api-put

Вернуться в «C#»