diff --git a/RMuseum/Controllers/FAQController.cs b/RMuseum/Controllers/FAQController.cs index 65e81c27..85282501 100644 --- a/RMuseum/Controllers/FAQController.cs +++ b/RMuseum/Controllers/FAQController.cs @@ -61,6 +61,58 @@ namespace RMuseum.Controllers return Ok(res.Result); } + /// + /// add a new faq category + /// + /// + /// + + [HttpPost("cat")] + [Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQCategory))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task AddCategoryAsync([FromBody]FAQCategory cat) + { + var res = await _faqService.AddCategoryAsync(cat); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + return Ok(res.Result); + } + + /// + /// update an existing faq category + /// + /// + /// + [HttpPut("cat")] + [Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQCategory))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task UpdateCategoryAsync([FromBody] FAQCategory cat) + { + var res = await _faqService.UpdateCategoryAsync(cat); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + return Ok(res.Result); + } + + /// + /// delete a faq category + /// + /// + /// + [HttpDelete("cat/{id}")] + [Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task DeleteCategoryAsync(int id) + { + var res = await _faqService.DeleteCategoryAsync(id); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + return Ok(res.Result); + } + /// /// get published pinned items /// @@ -130,6 +182,60 @@ namespace RMuseum.Controllers } + + /// + /// add a new faq item + /// + /// + /// + + [HttpPost] + [Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQCategory))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task AddItemAsync([FromBody] FAQItem item) + { + var res = await _faqService.AddItemAsync(item); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + return Ok(res.Result); + } + + /// + /// update an existing faq item + /// + /// + /// + [HttpPut] + [Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQCategory))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task UpdateItemAsync([FromBody] FAQItem item) + { + var res = await _faqService.UpdateItemAsync(item); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + return Ok(res.Result); + } + + /// + /// delete a faq item + /// + /// + /// + [HttpDelete("{id}")] + [Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task DeleteItemAsync(int id) + { + var res = await _faqService.DeleteItemAsync(id); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + return Ok(res.Result); + } + + /// /// FAQ Service /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index b54fb5aa..ad7083a7 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -772,6 +772,27 @@ + + + add a new faq category + + + + + + + update an existing faq category + + + + + + + delete a faq category + + + + get published pinned items @@ -798,6 +819,27 @@ + + + add a new faq item + + + + + + + update an existing faq item + + + + + + + delete a faq item + + + + FAQ Service