diff --git a/GanjooRazor/Pages/AudioClip.cshtml.cs b/GanjooRazor/Pages/AudioClip.cshtml.cs
index d4482bdb..7c062860 100644
--- a/GanjooRazor/Pages/AudioClip.cshtml.cs
+++ b/GanjooRazor/Pages/AudioClip.cshtml.cs
@@ -1,24 +1,27 @@
+using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
+using Newtonsoft.Json;
using RMuseum.Models.Ganjoor.ViewModels;
using RMuseum.Models.GanjoorAudio.ViewModels;
-using RMuseum.Services;
namespace GanjooRazor.Pages
{
public class AudioClipModel : PageModel
{
+ ///
+ /// HttpClient instance
+ ///
+ private readonly HttpClient _httpClient;
- private readonly IGanjoorService _ganjoorService;
-
-
- private readonly IRecitationService _recitationService;
-
- public AudioClipModel(IGanjoorService ganjoorService, IRecitationService recitationService)
+ ///
+ /// constructor
+ ///
+ ///
+ public AudioClipModel(HttpClient httpClient)
{
- _ganjoorService = ganjoorService;
- _recitationService = recitationService;
+ _httpClient = httpClient;
}
///
@@ -38,14 +41,15 @@ namespace GanjooRazor.Pages
return BadRequest();
}
- var res = await _recitationService.GetPublishedRecitationById(int.Parse(Request.Query["a"]));
+ var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/audio/published/{Request.Query["a"]}");
+ response.EnsureSuccessStatusCode();
+ Recitation = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
- Recitation = res.Result;
+ var responsePoem = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{Recitation.PoemId}?verseDetails=true&catInfo=true&rhymes=false&recitations=false&images=false&songs=false&comments=false&navigation=false");
+ responsePoem.EnsureSuccessStatusCode();
- var resPoem = await _ganjoorService.GetPoemById(Recitation.PoemId, true, false, false, false, false, false, false, true, false);
-
- Poem = resPoem.Result;
+ Poem = JsonConvert.DeserializeObject(await responsePoem.Content.ReadAsStringAsync());
return Page();