oqtane.framework/Oqtane.Server/Modules/HtmlText/Controllers/HtmlTextController.cs
2019-08-16 09:49:26 -04:00

55 lines
1.4 KiB
C#

using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Oqtane.Shared.Modules.HtmlText.Models;
using Oqtane.Server.Modules.HtmlText.Repository;
namespace Oqtane.Server.Modules.HtmlText.Controllers
{
[Route("{site}/api/[controller]")]
public class HtmlTextController : Controller
{
private IHtmlTextRepository htmltext;
public HtmlTextController(IHtmlTextRepository HtmlText)
{
htmltext = HtmlText;
}
// GET api/<controller>/5
[HttpGet("{id}")]
public HtmlTextInfo Get(int id)
{
return htmltext.GetHtmlText(id);
}
// POST api/<controller>
[HttpPost]
public HtmlTextInfo Post([FromBody] HtmlTextInfo HtmlText)
{
if (ModelState.IsValid)
{
HtmlText = htmltext.AddHtmlText(HtmlText);
}
return HtmlText;
}
// PUT api/<controller>/5
[HttpPut("{id}")]
public HtmlTextInfo Put(int id, [FromBody] HtmlTextInfo HtmlText)
{
if (ModelState.IsValid)
{
HtmlText = htmltext.UpdateHtmlText(HtmlText);
}
return HtmlText;
}
// DELETE api/<controller>/5
[HttpDelete("{id}")]
public void Delete(int id)
{
htmltext.DeleteHtmlText(id);
}
}
}