docs: #319 API for retrieving a poem sections

This commit is contained in:
Hamid Reza Mohammadi 2022-05-09 20:27:50 +04:30
parent b3b410edae
commit 99222c74f6
5 changed files with 62 additions and 1 deletions

View File

@ -2775,6 +2775,26 @@ namespace RMuseum.Controllers
return Ok(res.Result);
}
/// <summary>
/// get all poem sections
/// </summary>
/// <param name="poemId"></param>
/// <returns></returns>
[HttpGet]
[Route("sections/{poemId}")]
[AllowAnonymous]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<GanjoorPoemSection[]>))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> GetPoemSectionsAsync(int poemId)
{
var res =
await _ganjoorService.GetPoemSectionsAsync(poemId);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
return Ok(res.Result);
}
/// <summary>
/// start band couplets fix
/// </summary>

View File

@ -7,7 +7,7 @@ namespace RMuseum.Models.Ganjoor.ViewModels
/// </summary>
public class GanjoorPoemSectionCorrectionViewModel
{
// <summary>
/// <summary>
/// Correction Id
/// </summary>
public int Id { get; set; }

View File

@ -1700,6 +1700,13 @@
<param name="coupletIndex"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemSectionsAsync(System.Int32)">
<summary>
get all poem sections
</summary>
<param name="poemId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.StartOnTimeBandCoupletsFix">
<summary>
start band couplets fix
@ -12289,6 +12296,13 @@
<param name="coupletIndex"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetPoemSectionsAsync(System.Int32)">
<summary>
get all poem sections
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="T:RMuseum.Services.IGanjoorTranslationService">
<summary>
translation service implementation
@ -13920,6 +13934,13 @@
<param name="coupletIndex"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemSectionsAsync(System.Int32)">
<summary>
get all poem sections
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.StartOnTimeBandCoupletsFix">
<summary>
start band couplets fix

View File

@ -934,5 +934,12 @@ namespace RMuseum.Services
/// <param name="coupletIndex"></param>
/// <returns></returns>
Task<RServiceResult<GanjoorPoemSection[]>> GetCoupletSectionsAsync(int poemId, int coupletIndex);
/// <summary>
/// get all poem sections
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<RServiceResult<GanjoorPoemSection[]>> GetPoemSectionsAsync(int id);
}
}

View File

@ -629,6 +629,19 @@ namespace RMuseum.Services.Implementation
}
}
/// <summary>
/// get all poem sections
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPoemSection[]>> GetPoemSectionsAsync(int id)
{
var sections =
await _context.GanjoorPoemSections.AsNoTracking().Include(s => s.GanjoorMetre).Where(s => s.PoemId == id).OrderBy(s => s.SectionType).ThenBy(s => s.VerseType).ToArrayAsync();
return new RServiceResult<GanjoorPoemSection[]>(sections);
}
/// <summary>
/// start band couplets fix
/// </summary>