#243 disabling loading category poems by default
This commit is contained in:
parent
339b9f72b1
commit
a5fb6273db
@ -105,6 +105,7 @@ namespace RMuseum.Controllers
|
||||
/// poet by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("poet/{id}")]
|
||||
@ -112,13 +113,13 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoetCompleteViewModel))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> GetPoetById(int id)
|
||||
public async Task<IActionResult> GetPoetById(int id, bool catPoems = false)
|
||||
{
|
||||
var cacheKey = $"poet/byid/{id}";
|
||||
if (!_memoryCache.TryGetValue(cacheKey, out GanjoorPoetCompleteViewModel poet))
|
||||
{
|
||||
RServiceResult<GanjoorPoetCompleteViewModel> res =
|
||||
await _ganjoorService.GetPoetById(id);
|
||||
await _ganjoorService.GetPoetById(id, catPoems);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
if (res.Result == null)
|
||||
@ -354,7 +355,7 @@ namespace RMuseum.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var poet = await _ganjoorService.GetPoetById(id);
|
||||
var poet = await _ganjoorService.GetPoetById(id, false);
|
||||
IFormFile file = Request.Form.Files[0];
|
||||
RServiceResult<RImage> image = await _imageFileService.Add(file, null, file.FileName, Path.Combine(Configuration.GetSection("PictureFileService")["StoragePath"], "PoetImages"));
|
||||
if (!string.IsNullOrEmpty(image.ExceptionString))
|
||||
|
||||
@ -701,11 +701,12 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoetById(System.Int32)">
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoetById(System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
poet by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="catPoems"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoetByUrl(System.String)">
|
||||
@ -8854,18 +8855,20 @@
|
||||
<param name="includeBio"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoetById(System.Int32)">
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoetById(System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
get poet by idCra
|
||||
get poet by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="catPoems"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoetByUrl(System.String)">
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoetByUrl(System.String,System.Boolean)">
|
||||
<summary>
|
||||
get poet by url
|
||||
</summary>
|
||||
<param name="url"></param>
|
||||
<param name="catPoems"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoetImageIdByUrl(System.String)">
|
||||
@ -10907,18 +10910,20 @@
|
||||
<param name="includeBio"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoetById(System.Int32)">
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoetById(System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
get poet by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="catPoems"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoetByUrl(System.String)">
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoetByUrl(System.String,System.Boolean)">
|
||||
<summary>
|
||||
get poet by url
|
||||
</summary>
|
||||
<param name="url"></param>
|
||||
<param name="catPoems"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoetImageIdByUrl(System.String)">
|
||||
|
||||
@ -22,18 +22,20 @@ namespace RMuseum.Services
|
||||
Task<RServiceResult<GanjoorPoetViewModel[]>> GetPoets(bool published, bool includeBio = true);
|
||||
|
||||
/// <summary>
|
||||
/// get poet by idCra
|
||||
/// get poet by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetById(int id);
|
||||
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetById(int id, bool catPoems = false);
|
||||
|
||||
/// <summary>
|
||||
/// get poet by url
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetByUrl(string url);
|
||||
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetByUrl(string url, bool catPoems = false);
|
||||
|
||||
/// <summary>
|
||||
/// poet image id by url
|
||||
@ -48,7 +50,7 @@ namespace RMuseum.Services
|
||||
/// <param name="id"></param>
|
||||
/// <param name="poems"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatById(int id, bool poems = true);
|
||||
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatById(int id, bool poems = false);
|
||||
|
||||
/// <summary>
|
||||
/// get cat by url
|
||||
@ -56,7 +58,7 @@ namespace RMuseum.Services
|
||||
/// <param name="url"></param>
|
||||
/// <param name="poems"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatByUrl(string url, bool poems = true);
|
||||
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatByUrl(string url, bool poems = false);
|
||||
|
||||
/// <summary>
|
||||
/// get page by url
|
||||
@ -64,7 +66,7 @@ namespace RMuseum.Services
|
||||
/// <param name="url"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPageCompleteViewModel>> GetPageByUrl(string url, bool catPoems = true);
|
||||
Task<RServiceResult<GanjoorPageCompleteViewModel>> GetPageByUrl(string url, bool catPoems = false);
|
||||
|
||||
/// <summary>
|
||||
/// get page url by id
|
||||
|
||||
@ -89,8 +89,9 @@ namespace RMuseum.Services.Implementation
|
||||
/// get poet by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetById(int id)
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetById(int id, bool catPoems = false)
|
||||
{
|
||||
var cacheKey = $"/api/ganjoor/poet/{id}";
|
||||
|
||||
@ -100,7 +101,7 @@ namespace RMuseum.Services.Implementation
|
||||
if (poet == null)
|
||||
return new RServiceResult<GanjoorPoetCompleteViewModel>(null);
|
||||
var cat = await _context.GanjoorCategories.Where(c => c.ParentId == null && c.PoetId == id).AsNoTracking().FirstOrDefaultAsync();
|
||||
poetCat = (await GetCatById(cat.Id)).Result;
|
||||
poetCat = (await GetCatById(cat.Id, catPoems)).Result;
|
||||
if (poetCat != null)
|
||||
{
|
||||
_memoryCache.Set(cacheKey, poetCat);
|
||||
@ -113,8 +114,9 @@ namespace RMuseum.Services.Implementation
|
||||
/// get poet by url
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetByUrl(string url)
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetByUrl(string url, bool catPoems = false)
|
||||
{
|
||||
// /hafez/ => /hafez :
|
||||
if (url.LastIndexOf('/') == url.Length - 1)
|
||||
@ -124,7 +126,7 @@ namespace RMuseum.Services.Implementation
|
||||
var cat = await _context.GanjoorCategories.Where(c => c.FullUrl == url && c.ParentId == null).AsNoTracking().SingleOrDefaultAsync();
|
||||
if (cat == null)
|
||||
return new RServiceResult<GanjoorPoetCompleteViewModel>(null);
|
||||
return await GetCatById(cat.Id);
|
||||
return await GetCatById(cat.Id, catPoems);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -152,7 +154,7 @@ namespace RMuseum.Services.Implementation
|
||||
/// <param name="url"></param>
|
||||
/// <param name="poems"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatByUrl(string url, bool poems = true)
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatByUrl(string url, bool poems = false)
|
||||
{
|
||||
// /hafez/ => /hafez :
|
||||
if (url.LastIndexOf('/') == url.Length - 1)
|
||||
@ -171,7 +173,7 @@ namespace RMuseum.Services.Implementation
|
||||
/// <param name="id"></param>
|
||||
/// <param name="poems"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatById(int id, bool poems = true)
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatById(int id, bool poems = false)
|
||||
{
|
||||
var cat = await _context.GanjoorCategories.Include(c => c.Poet).Include(c => c.Parent).Where(c => c.Id == id).AsNoTracking().FirstOrDefaultAsync();
|
||||
if (cat == null)
|
||||
@ -370,7 +372,7 @@ namespace RMuseum.Services.Implementation
|
||||
/// <param name="url"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPageCompleteViewModel>> GetPageByUrl(string url, bool catPoems = true)
|
||||
public async Task<RServiceResult<GanjoorPageCompleteViewModel>> GetPageByUrl(string url, bool catPoems = false)
|
||||
{
|
||||
if (url.IndexOf('?') != -1)
|
||||
{
|
||||
@ -442,7 +444,7 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
case GanjoorPageType.CatPage:
|
||||
{
|
||||
var catRes = await GetCatById((int)dbPage.CatId);
|
||||
var catRes = await GetCatById((int)dbPage.CatId, catPoems);
|
||||
if (!string.IsNullOrEmpty(catRes.ExceptionString))
|
||||
{
|
||||
return new RServiceResult<GanjoorPageCompleteViewModel>(null, catRes.ExceptionString);
|
||||
@ -454,7 +456,7 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
if (dbPage.PoetId != null)
|
||||
{
|
||||
var poetRes = await GetPoetById((int)dbPage.PoetId);
|
||||
var poetRes = await GetPoetById((int)dbPage.PoetId, catPoems);
|
||||
if (!string.IsNullOrEmpty(poetRes.ExceptionString))
|
||||
{
|
||||
return new RServiceResult<GanjoorPageCompleteViewModel>(null, poetRes.ExceptionString);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user