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.
51 lines
1.1 KiB
C#
51 lines
1.1 KiB
C#
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" };
|
|
}
|
|
|
|
[System.Web.Http.Authorize]
|
|
public string Get(int id)
|
|
{
|
|
return id.ToString();
|
|
}
|
|
|
|
// POST api/values
|
|
public IHttpActionResult Post([FromBody]string value)
|
|
{
|
|
var cc = new System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult<string>
|
|
(
|
|
"",
|
|
new Dictionary<string, object> { { "id",2} },
|
|
"",
|
|
this
|
|
);
|
|
return cc;
|
|
}
|
|
|
|
// PUT api/values/5
|
|
public void Put(int id, [FromBody]string value)
|
|
{
|
|
}
|
|
|
|
// DELETE api/values/5
|
|
public void Delete(int id)
|
|
{
|
|
}
|
|
}
|
|
}
|