#418 get api for quoteds
This commit is contained in:
parent
1141cc4e52
commit
0d86d97809
@ -3692,6 +3692,31 @@ namespace RMuseum.Controllers
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get quoted poems
|
||||
/// </summary>
|
||||
/// <param name="poetId"></param>
|
||||
/// <param name="relatedPoetId"></param>
|
||||
/// <param name="chosen"></param>
|
||||
/// <param name="published"></param>
|
||||
/// <param name="claimed"></param>
|
||||
/// <param name="indirect"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("quoted")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorQuotedPoem[]))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetGanjoorQuotedPoemsAsync(int? poetId, int? relatedPoetId, bool? chosen, bool? published, bool? claimed, bool? indirect)
|
||||
{
|
||||
RServiceResult<GanjoorQuotedPoem[]> res =
|
||||
await _ganjoorService.GetGanjoorQuotedPoemsAsync(poetId, relatedPoetId, chosen, published, claimed, indirect);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2031,6 +2031,18 @@
|
||||
<param name="relatedId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetGanjoorQuotedPoemsAsync(System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{System.Boolean})">
|
||||
<summary>
|
||||
get quoted poems
|
||||
</summary>
|
||||
<param name="poetId"></param>
|
||||
<param name="relatedPoetId"></param>
|
||||
<param name="chosen"></param>
|
||||
<param name="published"></param>
|
||||
<param name="claimed"></param>
|
||||
<param name="indirect"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RMuseum.Controllers.GanjoorController.ReadOnlyMode">
|
||||
<summary>
|
||||
readonly mode
|
||||
@ -15481,6 +15493,18 @@
|
||||
<param name="relatedPoemId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetGanjoorQuotedPoemsAsync(System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{System.Boolean})">
|
||||
<summary>
|
||||
get quoted poems
|
||||
</summary>
|
||||
<param name="poetId"></param>
|
||||
<param name="relatedPoetId"></param>
|
||||
<param name="chosen"></param>
|
||||
<param name="published"></param>
|
||||
<param name="claimed"></param>
|
||||
<param name="indirect"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.IGanjoorTranslationService">
|
||||
<summary>
|
||||
translation service implementation
|
||||
@ -17457,6 +17481,18 @@
|
||||
<param name="metre"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetGanjoorQuotedPoemsAsync(System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{System.Boolean},System.Nullable{System.Boolean})">
|
||||
<summary>
|
||||
get quoted poems
|
||||
</summary>
|
||||
<param name="poetId"></param>
|
||||
<param name="relatedPoetId"></param>
|
||||
<param name="chosen"></param>
|
||||
<param name="published"></param>
|
||||
<param name="claimed"></param>
|
||||
<param name="indirect"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetGanjoorQuotedPoemsForPoemAsync(System.Int32,System.Int32,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
get quoted poems for a poem
|
||||
|
||||
@ -1234,5 +1234,17 @@ namespace RMuseum.Services
|
||||
/// <param name="relatedPoemId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorQuotedPoem[]>> GetGanjoorQuotedPoemsForRelatedAsync(int poemId, int relatedPoemId);
|
||||
|
||||
/// <summary>
|
||||
/// get quoted poems
|
||||
/// </summary>
|
||||
/// <param name="poetId"></param>
|
||||
/// <param name="relatedPoetId"></param>
|
||||
/// <param name="chosen"></param>
|
||||
/// <param name="published"></param>
|
||||
/// <param name="claimed"></param>
|
||||
/// <param name="indirect"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorQuotedPoem[]>> GetGanjoorQuotedPoemsAsync(int? poetId, int? relatedPoetId, bool? chosen, bool? published, bool? claimed, bool? indirect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,47 @@ namespace RMuseum.Services.Implementation
|
||||
/// </summary>
|
||||
public partial class GanjoorService : IGanjoorService
|
||||
{
|
||||
/// <summary>
|
||||
/// get quoted poems
|
||||
/// </summary>
|
||||
/// <param name="poetId"></param>
|
||||
/// <param name="relatedPoetId"></param>
|
||||
/// <param name="chosen"></param>
|
||||
/// <param name="published"></param>
|
||||
/// <param name="claimed"></param>
|
||||
/// <param name="indirect"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorQuotedPoem[]>> GetGanjoorQuotedPoemsAsync(int? poetId, int? relatedPoetId, bool? chosen, bool? published, bool? claimed, bool? indirect)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new RServiceResult<GanjoorQuotedPoem[]>(await
|
||||
_context.GanjoorQuotedPoems
|
||||
.AsNoTracking()
|
||||
.Where(r =>
|
||||
(poetId == null || r.PoetId == poetId)
|
||||
&&
|
||||
(chosen == null || r.ChosenForMainList == chosen)
|
||||
&&
|
||||
(relatedPoetId == null || r.RelatedPoetId == relatedPoetId)
|
||||
&&
|
||||
(published == null || r.Published == published)
|
||||
&&
|
||||
(claimed == null || r.ClaimedByBothPoets == claimed)
|
||||
&&
|
||||
(indirect == null || r.IndirectQuotation == indirect)
|
||||
)
|
||||
.OrderBy(r => r.PoetId).ThenBy(r => r.PoemId).ThenBy(r => r.SortOrder).ThenBy(r => r.CachedRelatedPoemPoetDeathYearInLHijri)
|
||||
.ToArrayAsync()
|
||||
);
|
||||
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<GanjoorQuotedPoem[]>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get quoted poems for a poem
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user