docs: #275 moderating suggested lines
This commit is contained in:
parent
6d926b3d28
commit
b469793eb6
@ -21,7 +21,7 @@ else
|
||||
<span class="inputlabel">شاعر: </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="@Html.Raw(Model.Poet.FullUrl)" target="_blank">@Model.Poet.Nickname</a>
|
||||
<a href="@Model.Poet.FullUrl.Substring(1)" target="_blank">@Model.Poet.Nickname</a>
|
||||
<input type="hidden" asp-for="Suggestion.Id" />
|
||||
<input type="hidden" asp-for="Suggestion.PoetId" />
|
||||
<input type="hidden" asp-for="Suggestion.LineOrder" />
|
||||
@ -53,7 +53,7 @@ else
|
||||
<table style="width:100%" class="noborder">
|
||||
<tr>
|
||||
<td>
|
||||
<button type="submit" name="reject1" id="reject1" style="width:100%;color:white;background-color:darkred">رد</button>
|
||||
<button type="submit" name="reject" id="reject" style="width:100%;color:white;background-color:darkred">رد</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@ -6,6 +6,7 @@ using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GanjooRazor.Areas.User.Pages
|
||||
@ -86,5 +87,56 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
|
||||
Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]);
|
||||
|
||||
if (Request.Form["next"].Count == 1)
|
||||
{
|
||||
return Redirect($"/User/SuggestedPoetSpecLines/?skip={Skip + 1}");
|
||||
}
|
||||
|
||||
Suggestion.Published = Request.Form["approve"].Count == 1;
|
||||
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
if(Suggestion.Published)
|
||||
{
|
||||
var putResponse = await secureClient.PutAsync($"{APIRoot.Url}/api/poetspecs", new StringContent(JsonConvert.SerializeObject(Suggestion), Encoding.UTF8, "application/json"));
|
||||
if (!putResponse.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await putResponse.Content.ReadAsStringAsync());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var deleteResponse = await secureClient.DeleteAsync($"{APIRoot.Url}/api/poetspecs/{Suggestion.Id}");
|
||||
if (!deleteResponse.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await deleteResponse.Content.ReadAsStringAsync());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(LastError))
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
return Redirect($"/User/SuggestedPoetSpecLines/?skip={Skip}");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user