improving tagging with digital sources
This commit is contained in:
parent
580ea1ef34
commit
b45c154fbd
@ -252,6 +252,7 @@
|
||||
function tagPoemsWithDigitalTag(catId) {
|
||||
|
||||
var tag = document.getElementById('digital-source-url-slug').value;
|
||||
var name = document.getElementById('digital-source-name').value;
|
||||
|
||||
if (!confirm('آیا از برچسبگذاری اشعار این بخش با منبع دیجیتال با نشانی '+tag+' اطمینان دارید؟')) return;
|
||||
|
||||
@ -261,7 +262,8 @@
|
||||
url: url,
|
||||
data: {
|
||||
id: catId,
|
||||
tag: tag
|
||||
tag: tag,
|
||||
name: name
|
||||
},
|
||||
error: function (e) {
|
||||
if (e.responseText == null)
|
||||
@ -776,11 +778,18 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="inputlabel">منبع دیجیتال بخش</span>
|
||||
<span class="inputlabel">اسلاگ منبع دیجیتال بخش</span>
|
||||
</td>
|
||||
<td>
|
||||
<input id="digital-source-url-slug" value="" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="inputlabel">نام منبع دیجیتال بخش (فقط برای منبع جدید)</span>
|
||||
</td>
|
||||
<td>
|
||||
<input id="digital-source-name" value="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@ -1,8 +1,4 @@
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GanjooRazor.Utils;
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
@ -11,6 +7,10 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
@ -562,18 +562,42 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSetCategoryDigitalSourceTagAsync(int id, string tag)
|
||||
public async Task<IActionResult> OnPostSetCategoryDigitalSourceTagAsync(int id, string tag, string name)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/source/{id}/{tag}", null);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/source?sourceUrlSlug={tag}");
|
||||
if(!response.IsSuccessStatusCode)
|
||||
{
|
||||
var res = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return new BadRequestObjectResult(res);
|
||||
}
|
||||
DigitalSource source = JsonConvert.DeserializeObject<DigitalSource>(await response.Content.ReadAsStringAsync());
|
||||
if (source == null)
|
||||
{
|
||||
if(string.IsNullOrEmpty(name))
|
||||
{
|
||||
return new BadRequestObjectResult("منبع وجود ندارد. باید نام آن را وارد کنید.");
|
||||
}
|
||||
source = new DigitalSource()
|
||||
{
|
||||
UrlSlug = tag,
|
||||
ShortName = name,
|
||||
FullName = name,
|
||||
SourceType = "همراهان گنجور"
|
||||
};
|
||||
}
|
||||
|
||||
HttpResponseMessage responsePost = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/source/{id}",
|
||||
new StringContent(JsonConvert.SerializeObject(source), Encoding.UTF8, "application/json")
|
||||
);
|
||||
if (!responsePost.IsSuccessStatusCode)
|
||||
{
|
||||
var res = JsonConvert.DeserializeObject<string>(await responsePost.Content.ReadAsStringAsync());
|
||||
return new BadRequestObjectResult(res);
|
||||
}
|
||||
return new OkObjectResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user