switching back to httpclient instead of db direct
This commit is contained in:
parent
cf3b10549c
commit
d93ae0c89a
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// HttpClient instance
|
||||
/// </summary>
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
private readonly IGanjoorService _ganjoorService;
|
||||
|
||||
|
||||
private readonly IRecitationService _recitationService;
|
||||
|
||||
public AudioClipModel(IGanjoorService ganjoorService, IRecitationService recitationService)
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="httpClient"></param>
|
||||
public AudioClipModel(HttpClient httpClient)
|
||||
{
|
||||
_ganjoorService = ganjoorService;
|
||||
_recitationService = recitationService;
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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<PublicRecitationViewModel>(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<GanjoorPoemCompleteViewModel>(await responsePoem.Content.ReadAsStringAsync());
|
||||
|
||||
return Page();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user