using DiwanRazor.Models.MuseumLink;
using DiwanRazor.Utils;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using RMuseum.Models.DiwanIntegration.ViewModels;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace DiwanRazor.Pages
{
public class PinModel : PageModel
{
///
دیوان میں داخلہ";
}
else
if (Request.Query["final"] == "1")
{
using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response)))
{
if(await DiwanSessionChecker.PrepareClient(secureClient, Request, Response))
{
PinterestLinkViewModel model = new PinterestLinkViewModel()
{
DiwanPostId = RelatedImageSuggestionModel.PoemId,
DiwanUrl = $"https://ganjoor.net{RelatedImageSuggestionModel.DiwanUrl}",
DiwanTitle = RelatedImageSuggestionModel.DiwanTitle,
AltText = RelatedImageSuggestionModel.AltText,
LinkType = RMuseum.Models.DiwanIntegration.LinkType.Pinterest,
PinterestUrl = RelatedImageSuggestionModel.PinterestUrl,
PinterestImageUrl = RelatedImageSuggestionModel.PinterestImageUrl
};
var stringContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
var response = await secureClient.PostAsync($"{APIRoot.Url}/api/artifacts/pinterest", stringContent);
if (response.StatusCode != HttpStatusCode.OK)
{
LastError = JsonConvert.DeserializeObject