#54 individual poet information
This commit is contained in:
parent
8963740a8c
commit
00a29085f6
@ -35,6 +35,25 @@ namespace RMuseum.Controllers
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// poet by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("poet/{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoetCompleteViewModel))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetPoetById(int id)
|
||||
{
|
||||
RServiceResult<GanjoorPoetCompleteViewModel> res =
|
||||
await _ganjoorService.GetPoetById(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get poem by id
|
||||
/// </summary>
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RMuseum.Models.Ganjoor.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Poet Complete Information
|
||||
/// </summary>
|
||||
public class GanjoorPoetCompleteViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// poet info
|
||||
/// </summary>
|
||||
public GanjoorPoet Poet { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// poet cat info
|
||||
/// </summary>
|
||||
public GanjoorCat Cat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// poet cat children
|
||||
/// </summary>
|
||||
public ICollection<GanjoorCat> Children { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// poems
|
||||
/// </summary>
|
||||
public ICollection<GanjoorPoem> Poems { get; set; }
|
||||
}
|
||||
}
|
||||
@ -622,6 +622,13 @@
|
||||
<param name="websitePoets"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoetById(System.Int32)">
|
||||
<summary>
|
||||
poet by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemById(System.Int32)">
|
||||
<summary>
|
||||
get poem by id
|
||||
@ -3436,6 +3443,31 @@
|
||||
Images
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetCompleteViewModel">
|
||||
<summary>
|
||||
Poet Complete Information
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetCompleteViewModel.Poet">
|
||||
<summary>
|
||||
poet info
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetCompleteViewModel.Cat">
|
||||
<summary>
|
||||
poet cat info
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetCompleteViewModel.Children">
|
||||
<summary>
|
||||
poet cat children
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetCompleteViewModel.Poems">
|
||||
<summary>
|
||||
poems
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.ImportJob.ImportJob">
|
||||
<summary>
|
||||
Import Job
|
||||
@ -4449,6 +4481,13 @@
|
||||
<param name="websitePoets"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoetById(System.Int32)">
|
||||
<summary>
|
||||
get poet by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoemById(System.Int32)">
|
||||
<summary>
|
||||
get poem by id
|
||||
@ -5195,6 +5234,20 @@
|
||||
<param name="websitePoets"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoetById(System.Int32)">
|
||||
<summary>
|
||||
get poet by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoetByUrl(System.String)">
|
||||
<summary>
|
||||
get poet by url
|
||||
</summary>
|
||||
<param name="url">base web site address should be removed: hafez or /hafez and not https://ganjoor.net/hafez </param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemById(System.Int32)">
|
||||
<summary>
|
||||
get poem by id
|
||||
|
||||
@ -19,6 +19,14 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoet[]>> GetPoets(bool websitePoets);
|
||||
|
||||
/// <summary>
|
||||
/// get poet by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetById(int id);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get poem by id
|
||||
/// </summary>
|
||||
|
||||
@ -40,12 +40,64 @@ namespace RMuseum.Services.Implementation
|
||||
.ToArrayAsync()
|
||||
);
|
||||
}
|
||||
catch(Exception exp)
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<GanjoorPoet[]>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get poet by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var poet = await _context.GanjoorPoets.Where(p => p.Id == id).FirstOrDefaultAsync();
|
||||
if (poet == null)
|
||||
return new RServiceResult<GanjoorPoetCompleteViewModel>(null);
|
||||
var cat = await _context.GanjoorCategories.Where(c => c.ParentId == null && c.PoetId == id).FirstOrDefaultAsync();
|
||||
|
||||
return new RServiceResult<GanjoorPoetCompleteViewModel>
|
||||
(
|
||||
new GanjoorPoetCompleteViewModel()
|
||||
{
|
||||
Poet = poet,
|
||||
Cat = cat,
|
||||
Children = await _context.GanjoorCategories.Where(c => c.ParentId == cat.Id).ToListAsync(),
|
||||
Poems = await _context.GanjoorPoems.Where(p => p.CatId == cat.Id).ToListAsync()
|
||||
}
|
||||
);
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
return new RServiceResult<GanjoorPoetCompleteViewModel>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get poet by url
|
||||
/// </summary>
|
||||
/// <param name="url">base web site address should be removed: hafez or /hafez and not https://ganjoor.net/hafez </param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetPoetByUrl(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
url = url.Replace("/", "");
|
||||
var cat = await _context.GanjoorCategories.Where(c => c.UrlSlug == url).SingleOrDefaultAsync();
|
||||
if (cat == null)
|
||||
return new RServiceResult<GanjoorPoetCompleteViewModel>(null);
|
||||
return await GetPoetById(cat.PoetId);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<GanjoorPoetCompleteViewModel>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get poem by id
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user