Merge branch 'main' of https://github.com/ganjoor/GanjoorService
This commit is contained in:
commit
d9bbd926c4
@ -43,7 +43,7 @@ namespace RMuseum.Controllers
|
||||
var cacheKey = $"ganjoor/poets";
|
||||
if (!_memoryCache.TryGetValue(cacheKey, out GanjoorPoetViewModel[] poets))
|
||||
{
|
||||
RServiceResult<GanjoorPoetViewModel[]> res =
|
||||
RServiceResult<GanjoorPoetViewModel[]> res =
|
||||
await _ganjoorService.GetPoets(true, false);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
@ -51,7 +51,7 @@ namespace RMuseum.Controllers
|
||||
poets = res.Result;
|
||||
if (AggressiveCacheEnabled)
|
||||
_memoryCache.Set(cacheKey, poets);
|
||||
|
||||
|
||||
}
|
||||
return Ok(poets);
|
||||
}
|
||||
@ -174,7 +174,7 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> ModifyPoet(int id, [FromBody]GanjoorPoetViewModel poet)
|
||||
public async Task<IActionResult> ModifyPoet(int id, [FromBody] GanjoorPoetViewModel poet)
|
||||
{
|
||||
|
||||
if (!string.IsNullOrEmpty(poet.ImageUrl))
|
||||
@ -317,7 +317,7 @@ namespace RMuseum.Controllers
|
||||
|
||||
lastModified = img.Result.LastModified;
|
||||
|
||||
|
||||
|
||||
|
||||
RServiceResult<string> imgPath = _imageFileService.GetImagePath(img.Result);
|
||||
if (!string.IsNullOrEmpty(imgPath.ExceptionString))
|
||||
@ -377,7 +377,7 @@ namespace RMuseum.Controllers
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
|
||||
if(res.Result)
|
||||
if (res.Result)
|
||||
{
|
||||
var cacheKey = $"poet/image/{poet.Result.Cat.UrlSlug}.png";
|
||||
if (_memoryCache.TryGetValue(cacheKey, out string imagePath))
|
||||
@ -419,7 +419,7 @@ namespace RMuseum.Controllers
|
||||
if (res.Result == null)
|
||||
return NotFound();
|
||||
cat = res.Result;
|
||||
if(AggressiveCacheEnabled)
|
||||
if (AggressiveCacheEnabled)
|
||||
{
|
||||
_memoryCache.Set(cacheKey, cat);
|
||||
}
|
||||
@ -456,7 +456,7 @@ namespace RMuseum.Controllers
|
||||
_memoryCache.Set(cacheKey, cat);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Ok(cat);
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ namespace RMuseum.Controllers
|
||||
try
|
||||
{
|
||||
Guid? imageId = null;
|
||||
if(Request.Form.Files.Count > 0)
|
||||
if (Request.Form.Files.Count > 0)
|
||||
{
|
||||
IFormFile file = Request.Form.Files[0];
|
||||
RServiceResult<RImage> image = await _imageFileService.Add(file, null, file.FileName, Path.Combine(Configuration.GetSection("PictureFileService")["StoragePath"], "CategoryImages"));
|
||||
@ -495,12 +495,12 @@ namespace RMuseum.Controllers
|
||||
|
||||
var res = await _ganjoorService.SetCategoryExtraInfo(id, Request.Form["bookName"], imageId, bool.Parse(Request.Form["sumUpSubsGeoLocations"]), Request.Form["mapName"]);
|
||||
|
||||
if(!string.IsNullOrEmpty(res.ExceptionString))
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
{
|
||||
return BadRequest(res.ExceptionString);
|
||||
}
|
||||
|
||||
if(res.Result == null)
|
||||
if (res.Result == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
@ -527,7 +527,7 @@ namespace RMuseum.Controllers
|
||||
public async Task<IActionResult> GenerateMissingBookCoversAsync()
|
||||
{
|
||||
var res = await _ganjoorService.GenerateMissingBookCoversAsync();
|
||||
if(!string.IsNullOrEmpty(res.ExceptionString))
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
@ -545,7 +545,7 @@ namespace RMuseum.Controllers
|
||||
public async Task<IActionResult> GetBooksAsync()
|
||||
{
|
||||
var books = await _ganjoorService.GetBooksAsync();
|
||||
if(!string.IsNullOrEmpty(books.ExceptionString))
|
||||
if (!string.IsNullOrEmpty(books.ExceptionString))
|
||||
{
|
||||
return BadRequest(books.ExceptionString);
|
||||
}
|
||||
@ -564,7 +564,7 @@ namespace RMuseum.Controllers
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPageCompleteViewModel))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> BatchRenameCatPoemTitles(int id, [FromBody]GanjoorBatchNamingModel model)
|
||||
public async Task<IActionResult> BatchRenameCatPoemTitles(int id, [FromBody] GanjoorBatchNamingModel model)
|
||||
{
|
||||
Guid userId =
|
||||
new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
|
||||
@ -755,7 +755,7 @@ namespace RMuseum.Controllers
|
||||
public async Task<IActionResult> GenerateTableOfContents(int id, GanjoorTOC options = GanjoorTOC.Analyse)
|
||||
{
|
||||
var res = await _ganjoorService.GenerateTableOfContents(id, options);
|
||||
if(!string.IsNullOrEmpty(res.ExceptionString))
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
@ -860,7 +860,7 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPageCompleteViewModel))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> ModifyPage(int id, [FromBody]GanjoorModifyPageViewModel page)
|
||||
public async Task<IActionResult> ModifyPage(int id, [FromBody] GanjoorModifyPageViewModel page)
|
||||
{
|
||||
Guid userId =
|
||||
new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
|
||||
@ -937,7 +937,7 @@ namespace RMuseum.Controllers
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// older versions of a page (modifications history except for current version)
|
||||
@ -957,7 +957,7 @@ namespace RMuseum.Controllers
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get old version of page
|
||||
/// </summary>
|
||||
@ -1269,7 +1269,7 @@ namespace RMuseum.Controllers
|
||||
var res = await _ganjoorService.DeletePoemSectionByPoemIdAndIndexAsync(poemId, sectionIndex, convertVerses);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
if(res.Result == false)
|
||||
if (res.Result == false)
|
||||
return NotFound();
|
||||
return Ok();
|
||||
}
|
||||
@ -1434,7 +1434,7 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<GanjoorPoemCorrectionViewModel>))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> GetPoemEffectiveCorrections(int id,[FromQuery] PagingParameterModel paging)
|
||||
public async Task<IActionResult> GetPoemEffectiveCorrections(int id, [FromQuery] PagingParameterModel paging)
|
||||
{
|
||||
var res =
|
||||
await _ganjoorService.GetPoemEffectiveCorrections(id, paging);
|
||||
@ -1972,7 +1972,7 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
[ProducesResponseType((int)HttpStatusCode.Forbidden)]
|
||||
public async Task<IActionResult> PublishAwaitingComment([FromBody]int id)
|
||||
public async Task<IActionResult> PublishAwaitingComment([FromBody] int id)
|
||||
{
|
||||
if (ReadOnlyMode)
|
||||
return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید.");
|
||||
@ -2181,7 +2181,7 @@ namespace RMuseum.Controllers
|
||||
{
|
||||
return BadRequest(res.ExceptionString);
|
||||
}
|
||||
if(!res.Result)
|
||||
if (!res.Result)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
@ -2377,7 +2377,7 @@ namespace RMuseum.Controllers
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get Similar Poems accroding to prosody and rhyme informations
|
||||
/// </summary>
|
||||
@ -2396,9 +2396,9 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<GanjoorPoemCompleteViewModel>))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
|
||||
public async Task<IActionResult> GetSimilarPoems([FromQuery]PagingParameterModel paging, string metre, string rhyme, int poetId = 0, int catId = 0, string language = "fa-IR", GanjoorPoemFormat format = GanjoorPoemFormat.Unknown)
|
||||
public async Task<IActionResult> GetSimilarPoems([FromQuery] PagingParameterModel paging, string metre, string rhyme, int poetId = 0, int catId = 0, string language = "fa-IR", GanjoorPoemFormat format = GanjoorPoemFormat.Unknown)
|
||||
{
|
||||
var pagedResult = await _ganjoorService.GetSimilarPoems(paging, metre, rhyme, poetId == 0 ? null : poetId, catId == 0 ? null : catId, language, format);
|
||||
var pagedResult = await _ganjoorService.GetSimilarPoems(paging, metre, rhyme, poetId == 0 ? null : poetId, catId == 0 ? null : catId, language, format);
|
||||
if (!string.IsNullOrEmpty(pagedResult.ExceptionString))
|
||||
return BadRequest(pagedResult.ExceptionString);
|
||||
|
||||
@ -2450,7 +2450,7 @@ namespace RMuseum.Controllers
|
||||
|
||||
public async Task<IActionResult> Search([FromQuery] PagingParameterModel paging, string term, int poetId = 0, int catId = 0)
|
||||
{
|
||||
var pagedResult = await _ganjoorService.Search(paging, term, poetId == 0 ? (int?)null : poetId, catId == 0 ? (int?)null: catId);
|
||||
var pagedResult = await _ganjoorService.Search(paging, term, poetId == 0 ? (int?)null : poetId, catId == 0 ? (int?)null : catId);
|
||||
if (!string.IsNullOrEmpty(pagedResult.ExceptionString))
|
||||
return BadRequest(pagedResult.ExceptionString);
|
||||
|
||||
@ -3656,16 +3656,17 @@ namespace RMuseum.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="itemsCount"></param>
|
||||
/// <param name="onlyClaimedByBothPoets"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("poem/{id}/quoteds")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorQuotedPoem[]))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetGanjoorQuotedPoemsAsync(int id, int skip, int itemsCount)
|
||||
public async Task<IActionResult> GetGanjoorQuotedPoemsForPoemAsync(int id, int skip, int itemsCount, bool onlyClaimedByBothPoets = false)
|
||||
{
|
||||
RServiceResult<GanjoorQuotedPoem[]> res =
|
||||
await _ganjoorService.GetGanjoorQuotedPoemsAsync(id, skip, itemsCount);
|
||||
await _ganjoorService.GetGanjoorQuotedPoemsForPoemAsync(id, skip, itemsCount, onlyClaimedByBothPoets);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
@ -3691,6 +3692,107 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get quoted by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("quoted/{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorQuotedPoem))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetGanjoorQuotedPoemByIdAsync(Guid id)
|
||||
{
|
||||
RServiceResult<GanjoorQuotedPoem> res =
|
||||
await _ganjoorService.GetGanjoorQuotedPoemByIdAsync(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// insert quoted
|
||||
/// </summary>
|
||||
/// <param name="quoted"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("quoted")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorQuotedPoem))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> InsertGanjoorQuotedPoemAsync([FromBody] GanjoorQuotedPoem quoted)
|
||||
{
|
||||
RServiceResult<GanjoorQuotedPoem> res =
|
||||
await _ganjoorService.InsertGanjoorQuotedPoemAsync(quoted);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// update quoted
|
||||
/// </summary>
|
||||
/// <param name="quoted"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("quoted")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> UpdateGanjoorQuotedPoemsAsync([FromBody] GanjoorQuotedPoem quoted)
|
||||
{
|
||||
RServiceResult<bool> res =
|
||||
await _ganjoorService.UpdateGanjoorQuotedPoemsAsync(quoted);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// delete quoted
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
[Route("quoted")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> DeleteGanjoorQuotedPoemByIdAsync(Guid id)
|
||||
{
|
||||
RServiceResult<bool> res =
|
||||
await _ganjoorService.DeleteGanjoorQuotedPoemByIdAsync(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -3771,10 +3873,10 @@ namespace RMuseum.Controllers
|
||||
/// <param name="memoryCache"></param>
|
||||
/// <param name="configuration"></param>
|
||||
public GanjoorController(
|
||||
IGanjoorService ganjoorService,
|
||||
IAppUserService appUserService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IImageFileService imageFileService,
|
||||
IGanjoorService ganjoorService,
|
||||
IAppUserService appUserService,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IImageFileService imageFileService,
|
||||
IMemoryCache memoryCache,
|
||||
IConfiguration configuration
|
||||
)
|
||||
|
||||
@ -2013,13 +2013,14 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetGanjoorQuotedPoemsAsync(System.Int32,System.Int32,System.Int32)">
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetGanjoorQuotedPoemsForPoemAsync(System.Int32,System.Int32,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
get quoted poems for a poem
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="skip"></param>
|
||||
<param name="itemsCount"></param>
|
||||
<param name="onlyClaimedByBothPoets"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetGanjoorQuotedPoemsForRelatedAsync(System.Int32,System.Int32)">
|
||||
@ -2030,6 +2031,46 @@
|
||||
<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="M:RMuseum.Controllers.GanjoorController.GetGanjoorQuotedPoemByIdAsync(System.Guid)">
|
||||
<summary>
|
||||
get quoted by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.InsertGanjoorQuotedPoemAsync(RMuseum.Models.Ganjoor.GanjoorQuotedPoem)">
|
||||
<summary>
|
||||
insert quoted
|
||||
</summary>
|
||||
<param name="quoted"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.UpdateGanjoorQuotedPoemsAsync(RMuseum.Models.Ganjoor.GanjoorQuotedPoem)">
|
||||
<summary>
|
||||
update quoted
|
||||
</summary>
|
||||
<param name="quoted"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.DeleteGanjoorQuotedPoemByIdAsync(System.Guid)">
|
||||
<summary>
|
||||
delete quoted
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RMuseum.Controllers.GanjoorController.ReadOnlyMode">
|
||||
<summary>
|
||||
readonly mode
|
||||
@ -15479,13 +15520,14 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetGanjoorQuotedPoemsAsync(System.Int32,System.Int32,System.Int32)">
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetGanjoorQuotedPoemsForPoemAsync(System.Int32,System.Int32,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
get quoted poems for a poem
|
||||
</summary>
|
||||
<param name="poemId"></param>
|
||||
<param name="skip"></param>
|
||||
<param name="itemsCount"></param>
|
||||
<param name="onlyClaimedByBothPoets"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetGanjoorQuotedPoemsForRelatedAsync(System.Int32,System.Int32)">
|
||||
@ -15496,6 +15538,46 @@
|
||||
<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="M:RMuseum.Services.IGanjoorService.GetGanjoorQuotedPoemByIdAsync(System.Guid)">
|
||||
<summary>
|
||||
get quoted by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.InsertGanjoorQuotedPoemAsync(RMuseum.Models.Ganjoor.GanjoorQuotedPoem)">
|
||||
<summary>
|
||||
insert quoted poem
|
||||
</summary>
|
||||
<param name="quoted"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.UpdateGanjoorQuotedPoemsAsync(RMuseum.Models.Ganjoor.GanjoorQuotedPoem)">
|
||||
<summary>
|
||||
update quoted poem
|
||||
</summary>
|
||||
<param name="quoted"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.DeleteGanjoorQuotedPoemByIdAsync(System.Guid)">
|
||||
<summary>
|
||||
delete quoted by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.IGanjoorTranslationService">
|
||||
<summary>
|
||||
translation service implementation
|
||||
@ -17472,13 +17554,54 @@
|
||||
<param name="metre"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetGanjoorQuotedPoemsAsync(System.Int32,System.Int32,System.Int32)">
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetGanjoorQuotedPoemByIdAsync(System.Guid)">
|
||||
<summary>
|
||||
get quoted by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.InsertGanjoorQuotedPoemAsync(RMuseum.Models.Ganjoor.GanjoorQuotedPoem)">
|
||||
<summary>
|
||||
insert quoted poem
|
||||
</summary>
|
||||
<param name="quoted"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.UpdateGanjoorQuotedPoemsAsync(RMuseum.Models.Ganjoor.GanjoorQuotedPoem)">
|
||||
<summary>
|
||||
update quoted poem
|
||||
</summary>
|
||||
<param name="quoted"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.DeleteGanjoorQuotedPoemByIdAsync(System.Guid)">
|
||||
<summary>
|
||||
delete quoted by id
|
||||
</summary>
|
||||
<param name="id"></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
|
||||
</summary>
|
||||
<param name="poemId"></param>
|
||||
<param name="skip"></param>
|
||||
<param name="itemsCount"></param>
|
||||
<param name="onlyClaimedByBothPoets"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetGanjoorQuotedPoemsForRelatedAsync(System.Int32,System.Int32)">
|
||||
|
||||
@ -1223,8 +1223,9 @@ namespace RMuseum.Services
|
||||
/// <param name="poemId"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="itemsCount"></param>
|
||||
/// <param name="onlyClaimedByBothPoets"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorQuotedPoem[]>> GetGanjoorQuotedPoemsAsync(int poemId, int skip, int itemsCount);
|
||||
Task<RServiceResult<GanjoorQuotedPoem[]>> GetGanjoorQuotedPoemsForPoemAsync(int poemId, int skip, int itemsCount, bool onlyClaimedByBothPoets);
|
||||
|
||||
/// <summary>
|
||||
/// two poems quoted records
|
||||
@ -1233,5 +1234,45 @@ 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);
|
||||
|
||||
/// <summary>
|
||||
/// get quoted by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorQuotedPoem>> GetGanjoorQuotedPoemByIdAsync(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// insert quoted poem
|
||||
/// </summary>
|
||||
/// <param name="quoted"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorQuotedPoem>> InsertGanjoorQuotedPoemAsync(GanjoorQuotedPoem quoted);
|
||||
|
||||
/// <summary>
|
||||
/// update quoted poem
|
||||
/// </summary>
|
||||
/// <param name="quoted"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> UpdateGanjoorQuotedPoemsAsync(GanjoorQuotedPoem quoted);
|
||||
|
||||
/// <summary>
|
||||
/// delete quoted by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> DeleteGanjoorQuotedPoemByIdAsync(Guid id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,21 +15,173 @@ namespace RMuseum.Services.Implementation
|
||||
/// </summary>
|
||||
public partial class GanjoorService : IGanjoorService
|
||||
{
|
||||
/// <summary>
|
||||
/// get quoted by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorQuotedPoem>> GetGanjoorQuotedPoemByIdAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new RServiceResult<GanjoorQuotedPoem>(await _context.GanjoorQuotedPoems.AsNoTracking().Where(q => q.Id == id).SingleAsync());
|
||||
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<GanjoorQuotedPoem>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// insert quoted poem
|
||||
/// </summary>
|
||||
/// <param name="quoted"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorQuotedPoem>> InsertGanjoorQuotedPoemAsync(GanjoorQuotedPoem quoted)
|
||||
{
|
||||
try
|
||||
{
|
||||
_context.Add(quoted);
|
||||
await _context.SaveChangesAsync();
|
||||
return new RServiceResult<GanjoorQuotedPoem>(quoted);
|
||||
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<GanjoorQuotedPoem>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// update quoted poem
|
||||
/// </summary>
|
||||
/// <param name="quoted"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> UpdateGanjoorQuotedPoemsAsync(GanjoorQuotedPoem quoted)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dbModel = await _context.GanjoorQuotedPoems.Where(q => q.Id == quoted.Id).SingleAsync();
|
||||
dbModel.PoemId = quoted.PoemId;
|
||||
dbModel.PoetId = quoted.PoetId;
|
||||
dbModel.RelatedPoetId = quoted.RelatedPoetId;
|
||||
dbModel.RelatedPoemId = quoted.RelatedPoemId;
|
||||
dbModel.IsPriorToRelated = quoted.IsPriorToRelated;
|
||||
dbModel.ChosenForMainList = quoted.ChosenForMainList;
|
||||
dbModel.CachedRelatedPoemPoetDeathYearInLHijri = quoted.CachedRelatedPoemPoetDeathYearInLHijri;
|
||||
dbModel.CachedRelatedPoemPoetName = quoted.CachedRelatedPoemPoetName;
|
||||
dbModel.CachedRelatedPoemPoetUrl = quoted.CachedRelatedPoemPoetUrl;
|
||||
dbModel.CachedRelatedPoemPoetImage = quoted.CachedRelatedPoemPoetImage;
|
||||
dbModel.CachedRelatedPoemFullTitle = quoted.CachedRelatedPoemFullTitle;
|
||||
dbModel.CachedRelatedPoemFullUrl = quoted.CachedRelatedPoemFullUrl;
|
||||
dbModel.SortOrder = quoted.SortOrder;
|
||||
dbModel.Note = quoted.Note;
|
||||
dbModel.Published = quoted.Published;
|
||||
dbModel.RelatedCoupletVerse1 = quoted.RelatedCoupletVerse1;
|
||||
dbModel.RelatedCoupletVerse1ShouldBeEmphasized = quoted.RelatedCoupletVerse1ShouldBeEmphasized;
|
||||
dbModel.RelatedCoupletVerse2 = quoted.RelatedCoupletVerse2;
|
||||
dbModel.RelatedCoupletVerse2ShouldBeEmphasized = quoted.RelatedCoupletVerse2ShouldBeEmphasized;
|
||||
dbModel.RelatedCoupletIndex = quoted.RelatedCoupletIndex;
|
||||
dbModel.CoupletVerse1 = quoted.CoupletVerse1;
|
||||
dbModel.CoupletVerse1ShouldBeEmphasized = quoted.CoupletVerse1ShouldBeEmphasized;
|
||||
dbModel.CoupletVerse2 = quoted.CoupletVerse2;
|
||||
dbModel.CoupletVerse2ShouldBeEmphasized = quoted.CoupletVerse2ShouldBeEmphasized;
|
||||
dbModel.CoupletIndex = quoted.CoupletIndex;
|
||||
dbModel.ClaimedByBothPoets = quoted.ClaimedByBothPoets;
|
||||
dbModel.IndirectQuotation = quoted.IndirectQuotation;
|
||||
dbModel.SamePoemsQuotedCount = quoted.SamePoemsQuotedCount;
|
||||
|
||||
_context.Update(dbModel);
|
||||
await _context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(true);
|
||||
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// delete quoted by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> DeleteGanjoorQuotedPoemByIdAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var q = await _context.GanjoorQuotedPoems.Where(q => q.Id == id).SingleAsync();
|
||||
_context.Remove(q);
|
||||
await _context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(true);
|
||||
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <param name="poemId"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="itemsCount"></param>
|
||||
/// <param name="onlyClaimedByBothPoets"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorQuotedPoem[]>> GetGanjoorQuotedPoemsAsync(int poemId, int skip, int itemsCount)
|
||||
public async Task<RServiceResult<GanjoorQuotedPoem[]>> GetGanjoorQuotedPoemsForPoemAsync(int poemId, int skip, int itemsCount, bool onlyClaimedByBothPoets)
|
||||
{
|
||||
try
|
||||
{
|
||||
var source =
|
||||
_context.GanjoorQuotedPoems
|
||||
.AsNoTracking()
|
||||
.Where(r => r.PoemId == poemId && r.ChosenForMainList == true)
|
||||
.Where(r => r.PoemId == poemId && r.ChosenForMainList == true
|
||||
&& (!onlyClaimedByBothPoets || r.ClaimedByBothPoets == true))
|
||||
.OrderBy(r => r.SortOrder).ThenBy(r => r.CachedRelatedPoemPoetDeathYearInLHijri);
|
||||
|
||||
if (itemsCount <= 0)
|
||||
@ -71,6 +223,7 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// extracting quoted poems
|
||||
/// </summary>
|
||||
|
||||
@ -1867,7 +1867,7 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<GanjoorPoemCompleteViewModel>(null, tagsRes.ExceptionString);
|
||||
PoemGeoDateTag[] geoDateTags = tagsRes.Result;
|
||||
|
||||
var quotedRes = await GetGanjoorQuotedPoemsAsync(id, 0, 6);
|
||||
var quotedRes = await GetGanjoorQuotedPoemsForPoemAsync(id, 0, 6, false);
|
||||
if (!string.IsNullOrEmpty(quotedRes.ExceptionString))
|
||||
return new RServiceResult<GanjoorPoemCompleteViewModel>(null, quotedRes.ExceptionString);
|
||||
GanjoorQuotedPoem[] quoteds = quotedRes.Result;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user