docs: #285 adding FAQController with GET methods
This commit is contained in:
parent
ba19ff19cf
commit
e9ee2de210
147
RMuseum/Controllers/FAQController.cs
Normal file
147
RMuseum/Controllers/FAQController.cs
Normal file
@ -0,0 +1,147 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RMuseum.Models.Auth.Memory;
|
||||
using RMuseum.Services;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using RMuseum.Models.FAQ;
|
||||
|
||||
namespace RMuseum.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/faq")]
|
||||
public class FAQController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// get published categories
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("cat")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQCategory[]))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetCategoriesAsync()
|
||||
{
|
||||
var res = await _faqService.GetCategoriesAsync(true);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
/// <summary>
|
||||
/// get all categories
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet("cat/secure")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQCategory[]))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetAllCategoriesAsync()
|
||||
{
|
||||
var res = await _faqService.GetCategoriesAsync(false);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get category by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("cat/secure/{id}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQCategory))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetCategoryByIdAsync(int id)
|
||||
{
|
||||
var res = await _faqService.GetCategoryByIdAsync(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get published pinned items
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("pinned")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQItem[]))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetPinnedItemsAsync()
|
||||
{
|
||||
var res = await _faqService.GetPinnedItemsAsync(true);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get published category items
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet("cat/items")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQItem[]))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetCategoryItemsAsync(int catId)
|
||||
{
|
||||
var res = await _faqService.GetCategoryItemsAsync(catId, true);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get all category items
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet("cat/items/secure")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQItem[]))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetAllCategoryItemsAsync(int catId)
|
||||
{
|
||||
var res = await _faqService.GetCategoryItemsAsync(catId, false);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get item by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("secure/{id}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.FAQEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FAQItem))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetItemByIdAsync(int id)
|
||||
{
|
||||
var res = await _faqService.GetItemByIdAsync(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// FAQ Service
|
||||
/// </summary>
|
||||
protected readonly IFAQService _faqService;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="faqService"></param>
|
||||
public FAQController(IFAQService faqService)
|
||||
{
|
||||
_faqService = faqService;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,6 +68,11 @@ namespace RMuseum.Models.Auth.Memory
|
||||
/// </summary>
|
||||
public const string GanjoorEntityShortName = "ganjoor";
|
||||
|
||||
/// <summary>
|
||||
/// FAQ contents
|
||||
/// </summary>
|
||||
public const string FAQEntityShortName = "faq";
|
||||
|
||||
///<summary>
|
||||
/// reorder
|
||||
/// </summary>
|
||||
@ -180,6 +185,15 @@ namespace RMuseum.Models.Auth.Memory
|
||||
new SecurableItemOperation(ModeratePoetPhotos, "مدیریت تصاویر شاعران", false),
|
||||
}
|
||||
},
|
||||
new SecurableItem()
|
||||
{
|
||||
ShortName = FAQEntityShortName,
|
||||
Description = "پرسشهای متداول",
|
||||
Operations = new SecurableItemOperation[]
|
||||
{
|
||||
new SecurableItemOperation(ModerateOperationShortName, "مدیریت", false),
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
@ -753,6 +753,62 @@
|
||||
donation service
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.FAQController.GetCategoriesAsync">
|
||||
<summary>
|
||||
get published categories
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.FAQController.GetAllCategoriesAsync">
|
||||
<summary>
|
||||
get all categories
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.FAQController.GetCategoryByIdAsync(System.Int32)">
|
||||
<summary>
|
||||
get category by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.FAQController.GetPinnedItemsAsync">
|
||||
<summary>
|
||||
get published pinned items
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.FAQController.GetCategoryItemsAsync(System.Int32)">
|
||||
<summary>
|
||||
get published category items
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.FAQController.GetAllCategoryItemsAsync(System.Int32)">
|
||||
<summary>
|
||||
get all category items
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.FAQController.GetItemByIdAsync(System.Int32)">
|
||||
<summary>
|
||||
get item by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:RMuseum.Controllers.FAQController._faqService">
|
||||
<summary>
|
||||
FAQ Service
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.FAQController.#ctor(RMuseum.Services.IFAQService)">
|
||||
<summary>
|
||||
constructor
|
||||
</summary>
|
||||
<param name="faqService"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoets">
|
||||
<summary>
|
||||
get list of published poets without their biography
|
||||
@ -3593,6 +3649,11 @@
|
||||
ganjoor contents
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:RMuseum.Models.Auth.Memory.RMuseumSecurableItem.FAQEntityShortName">
|
||||
<summary>
|
||||
FAQ contents
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:RMuseum.Models.Auth.Memory.RMuseumSecurableItem.ReOrderOperationShortName">
|
||||
<summary>
|
||||
reorder
|
||||
|
||||
Loading…
Reference in New Issue
Block a user