docs: #379 api for retrieving list of books

This commit is contained in:
Hamid Reza Mohammadi 2023-04-23 18:28:19 +03:30
parent 5a9f8a0dcc
commit 2717c801d5
5 changed files with 71 additions and 1 deletions

View File

@ -513,6 +513,26 @@ namespace RMuseum.Controllers
}
}
/// <summary>
/// list of books
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("books")]
[AllowAnonymous]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorCatViewModel[]))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> GetBooksAsync()
{
var books = await _ganjoorService.GetBooksAsync();
if(!string.IsNullOrEmpty(books.ExceptionString))
{
return BadRequest(books.ExceptionString);
}
return Ok(books);
}
/// <summary>
/// batch rename cat poems
/// </summary>

View File

@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Http;
using RSecurityBackend.Models.Image;
using System;
using System.Collections.Generic;

View File

@ -996,6 +996,12 @@
<param name="id"></param>
<returns>only RImageId field is valid</returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetBooksAsync">
<summary>
list of books
</summary>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.BatchRenameCatPoemTitles(System.Int32,RMuseum.Models.Ganjoor.ViewModels.GanjoorBatchNamingModel)">
<summary>
batch rename cat poems
@ -12520,6 +12526,12 @@
<param name="mapName"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetBooksAsync">
<summary>
get list of books
</summary>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetPageByUrl(System.String,System.Boolean)">
<summary>
get page by url
@ -15706,6 +15718,12 @@
<param name="mapName"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetBooksAsync">
<summary>
get list of books
</summary>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCatById(System.Int32,System.Boolean,System.Boolean)">
<summary>
get cat by id

View File

@ -73,6 +73,12 @@ namespace RMuseum.Services
/// <returns></returns>
Task<RServiceResult<GanjoorCatViewModel>> SetCategoryExtraInfo(int catId, string bookName, Guid? imageId, bool sumUpSubsGeoLocations, string mapName);
/// <summary>
/// get list of books
/// </summary>
/// <returns></returns>
Task<RServiceResult<GanjoorCatViewModel[]>> GetBooksAsync();
/// <summary>
/// get page by url
/// </summary>

View File

@ -245,6 +245,33 @@ namespace RMuseum.Services.Implementation
return new RServiceResult<GanjoorCatViewModel>(null, exp.ToString());
}
}
/// <summary>
/// get list of books
/// </summary>
/// <returns></returns>
public async Task<RServiceResult<GanjoorCatViewModel[]>> GetBooksAsync()
{
try
{
return new RServiceResult<GanjoorCatViewModel[]>
(
await _context.GanjoorCategories.AsNoTracking().Where(c => !string.IsNullOrEmpty(c.BookName)).OrderBy(c => c.BookName)
.Select(c => new GanjoorCatViewModel()
{
BookName = c.BookName,
FullUrl = c.FullUrl,
RImageId = c.RImageId
}
)
.ToArrayAsync()
);
}
catch (Exception exp)
{
return new RServiceResult<GanjoorCatViewModel[]>(null, exp.ToString());
}
}
/// <summary>
/// get cat by id