#385 batch poem format tagging in category editor - API added
This commit is contained in:
parent
0af1ce35da
commit
83925dd987
@ -623,11 +623,33 @@ namespace RMuseum.Controllers
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> SetCategoryLanguageTag(int id, string language)
|
||||
public async Task<IActionResult> SetCategoryLanguageTagAsync(int id, string language)
|
||||
{
|
||||
|
||||
var res =
|
||||
await _ganjoorService.SetCategoryLanguageTag(id, language);
|
||||
await _ganjoorService.SetCategoryLanguageTagAsync(id, language);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set category poems language tag
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="poemformat"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpPut]
|
||||
[Route("cat/poemformat/{id}/{poemformat}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> SetCategoryPoemFormatAsync(int id, GanjoorPoemFormat? poemformat)
|
||||
{
|
||||
|
||||
var res =
|
||||
await _ganjoorService.SetCategoryPoemFormatAsync(id, poemformat);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
|
||||
@ -1023,7 +1023,7 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.SetCategoryLanguageTag(System.Int32,System.String)">
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.SetCategoryLanguageTagAsync(System.Int32,System.String)">
|
||||
<summary>
|
||||
set category poems language tag
|
||||
</summary>
|
||||
@ -1031,6 +1031,14 @@
|
||||
<param name="language"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.SetCategoryPoemFormatAsync(System.Int32,System.Nullable{RMuseum.Models.Ganjoor.GanjoorPoemFormat})">
|
||||
<summary>
|
||||
set category poems language tag
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="poemformat"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.FindCategoryPoemsRhythms(System.Int32,System.Boolean,System.String)">
|
||||
<summary>
|
||||
start assigning poem rhythms
|
||||
@ -13434,7 +13442,7 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.SetCategoryLanguageTag(System.Int32,System.String)">
|
||||
<member name="M:RMuseum.Services.IGanjoorService.SetCategoryLanguageTagAsync(System.Int32,System.String)">
|
||||
<summary>
|
||||
set category poems language tag
|
||||
</summary>
|
||||
@ -13442,6 +13450,14 @@
|
||||
<param name="language"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.SetCategoryPoemFormatAsync(System.Int32,System.Nullable{RMuseum.Models.Ganjoor.GanjoorPoemFormat})">
|
||||
<summary>
|
||||
set category poem format tag for poems consisting of a single whole poem section
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<param name="format"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.StartRegeneratingTOCs(System.Guid)">
|
||||
<summary>
|
||||
regenerate TOCs
|
||||
@ -15165,7 +15181,15 @@
|
||||
<param name="q"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.SetCategoryLanguageTag(System.Int32,System.String)">
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.SetCategoryPoemFormatAsync(System.Int32,System.Nullable{RMuseum.Models.Ganjoor.GanjoorPoemFormat})">
|
||||
<summary>
|
||||
set category poem format tag for poems consisting of a single whole poem section
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<param name="format"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.SetCategoryLanguageTagAsync(System.Int32,System.String)">
|
||||
<summary>
|
||||
set category poems language tag
|
||||
</summary>
|
||||
|
||||
@ -959,7 +959,15 @@ namespace RMuseum.Services
|
||||
/// <param name="catId"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> SetCategoryLanguageTag(int catId, string language);
|
||||
Task<RServiceResult<bool>> SetCategoryLanguageTagAsync(int catId, string language);
|
||||
|
||||
/// <summary>
|
||||
/// set category poem format tag for poems consisting of a single whole poem section
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <param name="format"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> SetCategoryPoemFormatAsync(int catId, GanjoorPoemFormat? format);
|
||||
|
||||
/// <summary>
|
||||
/// regenerate TOCs
|
||||
|
||||
@ -21,13 +21,47 @@ namespace RMuseum.Services.Implementation
|
||||
/// </summary>
|
||||
public partial class GanjoorService : IGanjoorService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// set category poem format tag for poems consisting of a single whole poem section
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <param name="format"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> SetCategoryPoemFormatAsync(int catId, GanjoorPoemFormat? format)
|
||||
{
|
||||
try
|
||||
{
|
||||
var poemList = await _context.GanjoorPoems.Where(p => p.CatId == catId).ToListAsync();
|
||||
foreach (var poem in poemList)
|
||||
{
|
||||
var poemSections = await _context.GanjoorPoemSections.Where(s => s.PoemId == poem.Id && s.SectionType == PoemSectionType.WholePoem).ToListAsync();
|
||||
if(poemSections.Count == 1)
|
||||
{
|
||||
foreach (var section in poemSections)
|
||||
{
|
||||
section.PoemFormat = format;
|
||||
}
|
||||
_context.UpdateRange(poemSections);
|
||||
}
|
||||
}
|
||||
_context.UpdateRange(poemList);
|
||||
await _context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set category poems language tag
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> SetCategoryLanguageTag(int catId, string language)
|
||||
public async Task<RServiceResult<bool>> SetCategoryLanguageTagAsync(int catId, string language)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user