AddUserConroller.cs 595 B

123456789101112131415161718192021222324
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc;
  3. using BelovAPI.BaseConnection;
  4. using BelovAPI.ModelBase;
  5. namespace BelovAPI.Controllers
  6. {
  7. [Route("api/[controller]")]
  8. [ApiController]
  9. [ApiExplorerSettings(GroupName = "Действия с пользователем")]
  10. public class AddUserController : ControllerBase
  11. {
  12. ApplicationContext db = new ApplicationContext();
  13. [HttpPost]
  14. public IActionResult Index(User user)
  15. {
  16. db.Add(user);
  17. db.SaveChanges();
  18. return Ok(user);
  19. }
  20. }
  21. }