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 _users using the bogus library. He created the model class as User, 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?
I saw a wrong explanation in an explanation video, but it was explained correctly in the video. The codes are as follows friends. [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; } [/code] This was an API video. First, he defined fake data as _users using the bogus library. He created the model class as User, 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?