#418 delete quoted poem
This commit is contained in:
parent
1531dcb608
commit
0749d2dfc8
@ -75,6 +75,31 @@
|
||||
|
||||
}
|
||||
|
||||
function deleteThisOne(id) {
|
||||
if (!confirm('آیا از حذف این مورد اطمینان دارید؟'))
|
||||
return;
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: '',
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
error: function (e) {
|
||||
if (e.responseText == null)
|
||||
alert(e);
|
||||
else
|
||||
alert(e.responseText);
|
||||
},
|
||||
success: function () {
|
||||
alert('انجام شد.');
|
||||
location.reload(true);
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<form method="post">
|
||||
<table>
|
||||
@ -324,6 +349,10 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td><hr /></td></tr>
|
||||
<tr><td>
|
||||
<a role="button" onclick="deleteThisOne('@Model.GanjoorQuotedPoem.Id')" class="actionlink" title="حذف"><i class="noindent-info-button delete-icon"></i></a>
|
||||
</td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ using RMuseum.Models.Ganjoor;
|
||||
using GanjooRazor.Utils;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
||||
namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
@ -251,5 +252,27 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnDeleteAsync(string id)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/quoted?id={id}");
|
||||
|
||||
if (response.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync()));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return new BadRequestObjectResult("لطفاً از گنجور خارج و مجددا به آن وارد شوید.");
|
||||
}
|
||||
}
|
||||
return new JsonResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user