CsharpTemplate/APITemplate/Controllers/ExampleController.cs
2023-10-27 19:00:41 +07:00

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;
}
}
}
}