allow exception of poets in the similars page

#469
This commit is contained in:
Hamid Reza Mohammadi 2025-02-27 18:00:32 +03:30
parent 2fb283421c
commit 8f10475ec6
4 changed files with 15 additions and 7 deletions

View File

@ -2423,6 +2423,7 @@ namespace RMuseum.Controllers
/// <param name="term"></param>
/// <param name="coupletCountsFrom"></param>
/// <param name="coupletCountsTo"></param>
/// <param name="e"></param>
/// <returns>return value is not complete or valid for some parts, you should use only the valid parts!</returns>
[HttpGet]
@ -2431,9 +2432,9 @@ namespace RMuseum.Controllers
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<GanjoorPoemCompleteViewModel>))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task<IActionResult> GetSimilarPoemsAsync([FromQuery] PagingParameterModel paging, string metre, string rhyme, int poetId = 0, int catId = 0, string language = "fa-IR", GanjoorPoemFormat format = GanjoorPoemFormat.Unknown, string term = null, int coupletCountsFrom = 0, int coupletCountsTo = 0)
public async Task<IActionResult> GetSimilarPoemsAsync([FromQuery] PagingParameterModel paging, string metre, string rhyme, int poetId = 0, int catId = 0, string language = "fa-IR", GanjoorPoemFormat format = GanjoorPoemFormat.Unknown, string term = null, int coupletCountsFrom = 0, int coupletCountsTo = 0, int[] e = null)
{
var pagedResult = await _ganjoorService.GetSimilarPoemsAsync(paging, metre, rhyme, poetId == 0 ? null : poetId, catId == 0 ? null : catId, language, format, term, coupletCountsFrom, coupletCountsTo);
var pagedResult = await _ganjoorService.GetSimilarPoemsAsync(paging, metre, rhyme, poetId == 0 ? null : poetId, catId == 0 ? null : catId, language, format, term, coupletCountsFrom, coupletCountsTo, e == null ? [] : e);
if (!string.IsNullOrEmpty(pagedResult.ExceptionString))
return BadRequest(pagedResult.ExceptionString);

View File

@ -1672,7 +1672,7 @@
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetSimilarPoemsAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.String,System.String,System.Int32,System.Int32,System.String,RMuseum.Models.Ganjoor.GanjoorPoemFormat,System.String,System.Int32,System.Int32)">
<member name="M:RMuseum.Controllers.GanjoorController.GetSimilarPoemsAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.String,System.String,System.Int32,System.Int32,System.String,RMuseum.Models.Ganjoor.GanjoorPoemFormat,System.String,System.Int32,System.Int32,System.Int32[])">
<summary>
Get Similar Poems accroding to prosody and rhyme informations
</summary>
@ -1686,6 +1686,7 @@
<param name="term"></param>
<param name="coupletCountsFrom"></param>
<param name="coupletCountsTo"></param>
<param name="e"></param>
<returns>return value is not complete or valid for some parts, you should use only the valid parts!</returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetLanguageTaggedPoemSections(RSecurityBackend.Models.Generic.PagingParameterModel,System.String,System.Int32)">
@ -16448,7 +16449,7 @@
<param name="paging"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetSimilarPoemsAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.String,System.String,System.Nullable{System.Int32},System.Nullable{System.Int32},System.String,RMuseum.Models.Ganjoor.GanjoorPoemFormat,System.String,System.Int32,System.Int32)">
<member name="M:RMuseum.Services.IGanjoorService.GetSimilarPoemsAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.String,System.String,System.Nullable{System.Int32},System.Nullable{System.Int32},System.String,RMuseum.Models.Ganjoor.GanjoorPoemFormat,System.String,System.Int32,System.Int32,System.Int32[])">
<summary>
Get Similar Poems accroding to prosody and rhyme informations
</summary>
@ -16462,6 +16463,7 @@
<param name="term"></param>
<param name="coupletCountsFrom"></param>
<param name="coupletCountsTo"></param>
<param name="exceptPoetId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetLanguageTaggedPoemSections(RSecurityBackend.Models.Generic.PagingParameterModel,System.String,System.Nullable{System.Int32})">
@ -20565,7 +20567,7 @@
<param name="recitation"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetSimilarPoemsAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.String,System.String,System.Nullable{System.Int32},System.Nullable{System.Int32},System.String,RMuseum.Models.Ganjoor.GanjoorPoemFormat,System.String,System.Int32,System.Int32)">
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetSimilarPoemsAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.String,System.String,System.Nullable{System.Int32},System.Nullable{System.Int32},System.String,RMuseum.Models.Ganjoor.GanjoorPoemFormat,System.String,System.Int32,System.Int32,System.Int32[])">
<summary>
Get Similar Poems accroding to prosody and rhyme informations
</summary>
@ -20579,6 +20581,7 @@
<param name="term"></param>
<param name="coupletCountsFrom"></param>
<param name="coupletCountsTo"></param>
<param name="exceptPoetId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetLanguageTaggedPoemSections(RSecurityBackend.Models.Generic.PagingParameterModel,System.String,System.Nullable{System.Int32})">

View File

@ -495,8 +495,9 @@ namespace RMuseum.Services
/// <param name="term"></param>
/// <param name="coupletCountsFrom"></param>
/// <param name="coupletCountsTo"></param>
/// <param name="exceptPoetId"></param>
/// <returns></returns>
Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorPoemCompleteViewModel[] Items)>> GetSimilarPoemsAsync(PagingParameterModel paging, string metre, string rhyme, int? poetId, int? catId, string language = "fa-IR", GanjoorPoemFormat format = GanjoorPoemFormat.Unknown, string term = null, int coupletCountsFrom = 0, int coupletCountsTo = 0);
Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorPoemCompleteViewModel[] Items)>> GetSimilarPoemsAsync(PagingParameterModel paging, string metre, string rhyme, int? poetId, int? catId, string language, GanjoorPoemFormat format , string term , int coupletCountsFrom , int coupletCountsTo , int[] exceptPoetId );
/// <summary>
/// language tagged poem sections

View File

@ -2543,8 +2543,9 @@ namespace RMuseum.Services.Implementation
/// <param name="term"></param>
/// <param name="coupletCountsFrom"></param>
/// <param name="coupletCountsTo"></param>
/// <param name="exceptPoetId"></param>
/// <returns></returns>
public async Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorPoemCompleteViewModel[] Items)>> GetSimilarPoemsAsync(PagingParameterModel paging, string metre, string rhyme, int? poetId, int? catId, string language = "fa-IR", GanjoorPoemFormat format = GanjoorPoemFormat.Unknown, string term = null, int coupletCountsFrom = 0, int coupletCountsTo = 0)
public async Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorPoemCompleteViewModel[] Items)>> GetSimilarPoemsAsync(PagingParameterModel paging, string metre, string rhyme, int? poetId, int? catId, string language, GanjoorPoemFormat format , string term , int coupletCountsFrom, int coupletCountsTo, int[] exceptPoetId)
{
if (poetId == null)
{
@ -2583,6 +2584,8 @@ namespace RMuseum.Services.Implementation
.Where(s =>
(poetId == null || s.PoetId == poetId)
&&
(exceptPoetId.Length == 0 || !exceptPoetId.Contains(s.PoetId ?? 0))
&&
((language == "fa-IR" && string.IsNullOrEmpty(s.Language)) || s.Language == language)
&&
(string.IsNullOrEmpty(metre) || (metre == "null" && s.GanjoorMetreId == null) || (!string.IsNullOrEmpty(metre) && s.GanjoorMetre.Rhythm == metre))