ValuesController.cs 1014 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Mvc;
  6. namespace api.Controllers
  7. {
  8. [Route("api/[controller]")]
  9. [ApiController]
  10. public class ValuesController : ControllerBase
  11. {
  12. // GET api/values
  13. [HttpGet]
  14. public ActionResult<IEnumerable<string>> Get()
  15. {
  16. return new string[] { "value1", "value2" };
  17. }
  18. // GET api/values/5
  19. [HttpGet("{id}")]
  20. public ActionResult<string> Get(int id)
  21. {
  22. return "value";
  23. }
  24. // POST api/values
  25. [HttpPost]
  26. public void Post([FromBody] string value)
  27. {
  28. }
  29. // PUT api/values/5
  30. [HttpPut("{id}")]
  31. public void Put(int id, [FromBody] string value)
  32. {
  33. }
  34. // DELETE api/values/5
  35. [HttpDelete("{id}")]
  36. public void Delete(int id)
  37. {
  38. }
  39. }
  40. }