ChangeUser.cs 680 B

1234567891011121314151617181920212223
  1. using BelovAPI.BaseConnection;
  2. using BelovAPI.ModelBase;
  3. using Microsoft.AspNetCore.Mvc;
  4. namespace BelovAPI.Controllers
  5. {
  6. [Route("api/[controller]")]
  7. [ApiController]
  8. [ApiExplorerSettings(GroupName = "Действия с пользователем")]
  9. public class ChangeUser : Controller
  10. {
  11. ApplicationContext db = new ApplicationContext();
  12. [HttpPut]
  13. public IActionResult Index(User NewUser, int id)
  14. {
  15. User user = db.User.FirstOrDefault(x => x.Id == id);
  16. user.nameUser = NewUser.nameUser;
  17. user.Age = NewUser.Age;
  18. db.SaveChanges();
  19. return Ok(user);
  20. }
  21. }
  22. }