From c23b561e78b2ab64f66fc3245f0dff0a4c66b2ab Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Thu, 15 Apr 2021 09:40:15 +0430 Subject: [PATCH] #105 list of rhythms --- RMuseum/Controllers/GanjoorController.cs | 21 +++++++++++++++++++ RMuseum/RMuseum.xml | 18 ++++++++++++++++ RMuseum/Services/IGanjoorService.cs | 6 ++++++ .../Services/Implementation/GanjoorService.cs | 16 ++++++++++++++ 4 files changed, 61 insertions(+) diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index 132c17f3..e4af9ef2 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -910,6 +910,27 @@ namespace RMuseum.Controllers return Ok(pagedResult.Result.Items); } + /// + /// returns ganjoor metre list ordered by rhythm + /// + /// + + [HttpGet] + [Route("rhythms")] + [AllowAnonymous] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + + public async Task GetGanjoorMetres() + { + var res = await _ganjoorService.GetGanjoorMetres(); + + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + + return Ok(res.Result); + } + /// /// Ganjoor Service /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index dbdcb31d..73b1a0d3 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -877,6 +877,12 @@ send 0 for all return value is not complete or valid for some parts, you should use only the valid parts! + + + returns ganjoor metre list ordered by rhythm + + + Ganjoor Service @@ -6612,6 +6618,12 @@ + + + returns metre list (ordered by Rhythm) + + + get a random poem from hafez @@ -7626,6 +7638,12 @@ + + + returns metre list (ordered by Rhythm) + + + Database Context diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs index ae2a8ecd..d1220faa 100644 --- a/RMuseum/Services/IGanjoorService.cs +++ b/RMuseum/Services/IGanjoorService.cs @@ -251,6 +251,12 @@ namespace RMuseum.Services /// Task> ModifyPage(int id, Guid editingUserId, GanjoorModifyPageViewModel pageData); + /// + /// returns metre list (ordered by Rhythm) + /// + /// + Task> GetGanjoorMetres(); + /// /// get a random poem from hafez /// diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 540aabcf..3084a333 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -1861,6 +1861,22 @@ namespace RMuseum.Services.Implementation } } + /// + /// returns metre list (ordered by Rhythm) + /// + /// + public async Task> GetGanjoorMetres() + { + try + { + return new RServiceResult(await _context.GanjoorMetres.OrderBy(m => m.Rhythm).ToArrayAsync()); + } + catch(Exception exp) + { + return new RServiceResult(null, exp.ToString()); + } + } + /// /// Database Context ///