33 lines
703 B
C#
33 lines
703 B
C#
|
using APITemplate.Models;
|
|||
|
using APITemplate.Services;
|
|||
|
using Microsoft.AspNetCore.Http;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
|||
|
namespace APITemplate.Controllers
|
|||
|
{
|
|||
|
public class ExampleController : Controller
|
|||
|
{
|
|||
|
private ExampleService _svc;
|
|||
|
public ExampleController(ExampleService svc)
|
|||
|
{
|
|||
|
_svc = svc;
|
|||
|
}
|
|||
|
|
|||
|
// POST: ExampleController/Create
|
|||
|
[HttpPost]
|
|||
|
[ValidateAntiForgeryToken]
|
|||
|
public ActionResult Create(Example e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
_svc.Insert(e);
|
|||
|
return Created("",e);
|
|||
|
}
|
|||
|
catch
|
|||
|
{
|
|||
|
throw;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|