1 @inherits Microsoft.VisualStudio.Web.CodeGeneration.Templating.RazorTemplateBase
3 using System.Collections.Generic;
5 using System.Threading.Tasks;
6 using Microsoft.AspNetCore.Http;
7 using Microsoft.AspNetCore.Mvc;
9 @{string modelName = (Model.ClassName.EndsWith("Controller") ? Model.ClassName.Substring(0, Model.ClassName.Length - 10) : Model.ClassName);}
10 namespace @Model.NamespaceName
13 string routePrefix = "api/" + modelName;
15 [Produces("application/json")]
16 [Route("@routePrefix")]
17 public class @Model.ClassName : Controller
19 // GET: api/@modelName
21 public IEnumerable<string> Get()
23 return new string[] { "value1", "value2" };
26 // GET: api/@modelName/5
27 [HttpGet("{id}", Name = "Get")]
28 public string Get(int id)
33 // POST: api/@modelName
35 public void Post([FromBody]string value)
39 // PUT: api/@modelName/5
41 public void Put(int id, [FromBody]string value)
45 // DELETE: api/ApiWithActions/5
47 public void Delete(int id)