You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xUnitStudy/xUnitStudy.WebApi/Controllers/ValuesController.cs

51 lines
1.1 KiB
C#

7 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Mvc;
using Newtonsoft.Json;
namespace xUnitStudy.WebApi.Controllers
{
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
6 years ago
[System.Web.Http.Authorize]
7 years ago
public string Get(int id)
{
return id.ToString();
}
// POST api/values
6 years ago
public IHttpActionResult Post([FromBody]string value)
7 years ago
{
6 years ago
var cc = new System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult<string>
(
"",
new Dictionary<string, object> { { "id",2} },
"",
this
);
return cc;
7 years ago
}
// PUT api/values/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/values/5
public void Delete(int id)
{
}
}
}