parent
93b7f6d484
commit
295bdad5e1
40
GanjooRazor/Areas/Admin/Pages/CatDel.cshtml
Normal file
40
GanjooRazor/Areas/Admin/Pages/CatDel.cshtml
Normal file
@ -0,0 +1,40 @@
|
||||
@page
|
||||
@model GanjooRazor.Areas.Admin.Pages.CatDelModel
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@{
|
||||
Layout = "_AdminLayout";
|
||||
ViewData["Title"] = "حذف بخش";
|
||||
}
|
||||
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.LastResult))
|
||||
{
|
||||
<p>
|
||||
@Model.LastResult
|
||||
</p>
|
||||
<p>
|
||||
<a role="button" href="/" class="actionlink">برگشت</a>
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
آیا از حذف @Model.Cat.Cat.Title اطمینان دارید؟
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<form method="post" action="/Admin/CatDel?id=@Model.Cat.Cat.Id">
|
||||
<input type="submit" value="بله" />
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<a role="button" href="/Admin" class="actionlink">خیر / برگشت</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
}
|
||||
|
||||
83
GanjooRazor/Areas/Admin/Pages/CatDel.cshtml.cs
Normal file
83
GanjooRazor/Areas/Admin/Pages/CatDel.cshtml.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
||||
public class CatDelModel : PageModel
|
||||
{
|
||||
/// <summary>
|
||||
/// HttpClient instance
|
||||
/// </summary>
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="httpClient"></param>
|
||||
public CatDelModel(HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// category
|
||||
/// </summary>
|
||||
public GanjoorPoetCompleteViewModel Cat { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// last result
|
||||
/// </summary>
|
||||
public string LastResult { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Request.Cookies["Token"]))
|
||||
return Redirect("/");
|
||||
|
||||
LastResult = "";
|
||||
var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/cat/{Request.Query["id"]}");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastResult = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
Cat = JObject.Parse(await response.Content.ReadAsStringAsync()).ToObject<GanjoorPoetCompleteViewModel>();
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
LastResult = "";
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response);
|
||||
|
||||
|
||||
|
||||
var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/cat/{Request.Query["id"]}");
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastResult = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
else
|
||||
{
|
||||
LastResult = "عملیات حذف بخش انجام شد.";
|
||||
}
|
||||
|
||||
|
||||
return Page();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -765,6 +765,8 @@
|
||||
|
||||
<p><a href="/Admin/CatTrans?id=@Model.Cat.Cat.Id">انتقال بخش</a></p>
|
||||
|
||||
<p><a href="/Admin/CatDel?id=@Model.Cat.Cat.Id">حذف بخش</a></p>
|
||||
|
||||
|
||||
<p><a role="button" onclick="regenRelatedSections(@Model.Cat.Cat.Id)" class="actionlink" title="بازسازی قطعات مرتبط">بازسازی قطعات مرتبط</a></p>
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Threading.Tasks;
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
|
||||
@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RMuseum", "RMuseum\RMuseum.
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GanjooRazor", "GanjooRazor\GanjooRazor.csproj", "{48F9CDFA-625F-4743-BF21-BD556F6F33E8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TajikGanjoor", "TajikGanjoor\TajikGanjoor.csproj", "{1C51EB06-5190-4646-84C7-5EE712C86F57}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TajikGanjoor", "TajikGanjoor\TajikGanjoor.csproj", "{1C51EB06-5190-4646-84C7-5EE712C86F57}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
Loading…
Reference in New Issue
Block a user