diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index f0fdf4db..5c94e690 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -24,11 +24,11 @@ namespace RMuseum.Controllers [HttpGet] [Route("poets")] [AllowAnonymous] - [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoet[]))] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoetViewModel[]))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] public async Task GetPoets(bool websitePoets = true) { - RServiceResult res = + RServiceResult res = await _ganjoorService.GetPoets(websitePoets); if (!string.IsNullOrEmpty(res.ExceptionString)) return BadRequest(res.ExceptionString); diff --git a/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetCompleteViewModel.cs b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetCompleteViewModel.cs index 82f9ac8d..95b34ea9 100644 --- a/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetCompleteViewModel.cs +++ b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetCompleteViewModel.cs @@ -8,7 +8,7 @@ /// /// poet info /// - public GanjoorPoet Poet { get; set; } + public GanjoorPoetViewModel Poet { get; set; } /// /// poet cat info diff --git a/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetViewModel.cs b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetViewModel.cs new file mode 100644 index 00000000..1727ed8a --- /dev/null +++ b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoetViewModel.cs @@ -0,0 +1,28 @@ +namespace RMuseum.Models.Ganjoor.ViewModels +{ + /// + /// Ganjoor Poet + /// + public class GanjoorPoetViewModel + { + /// + /// id + /// + public int Id { get; set; } + + /// + /// name + /// + public string Name { get; set; } + + /// + /// description + /// + public string Description { get; set; } + + /// + /// urlslug + /// + public string FullUrl { get; set; } + } +} diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index b0e632e5..95a3c889 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -3525,6 +3525,31 @@ poet cat info + + + Ganjoor Poet + + + + + id + + + + + name + + + + + description + + + + + urlslug + + Import Job diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs index a05a9285..c6303213 100644 --- a/RMuseum/Services/IGanjoorService.cs +++ b/RMuseum/Services/IGanjoorService.cs @@ -17,7 +17,7 @@ namespace RMuseum.Services /// /// /// - Task> GetPoets(bool websitePoets); + Task> GetPoets(bool websitePoets); /// /// get poet by id diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index eca90339..aa115878 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -29,21 +29,31 @@ namespace RMuseum.Services.Implementation /// /// /// - public async Task> GetPoets(bool websitePoets) + public async Task> GetPoets(bool websitePoets) { try { - return new RServiceResult + return new RServiceResult ( await _context.GanjoorPoets .Where(p => !websitePoets || p.Id < 200) .OrderBy(p => p.Name) + .Select + ( + p => new GanjoorPoetViewModel() + { + Id = p.Id, + Name = p.Name, + Description = p.Description, + FullUrl = _context.GanjoorCategories.Where(c => c.PoetId == p.Id && c.ParentId == null).Single().FullUrl + } + ) .ToArrayAsync() ); } catch (Exception exp) { - return new RServiceResult(null, exp.ToString()); + return new RServiceResult(null, exp.ToString()); } } @@ -128,7 +138,14 @@ namespace RMuseum.Services.Implementation ( new GanjoorPoetCompleteViewModel() { - Poet = await _context.GanjoorPoets.Where(p => p.Id == cat.PoetId).FirstOrDefaultAsync(), + Poet = await _context.GanjoorPoets.Where(p => p.Id == cat.PoetId) + .Select(p => new GanjoorPoetViewModel() + { + Id = p.Id, + Name = p.Name, + Description = p.Description, + FullUrl = _context.GanjoorCategories.Where(c => c.PoetId == p.Id && c.ParentId == null).Single().FullUrl + }) .FirstOrDefaultAsync(), Cat = catViewModel } );