docs: a utility to batch rename category's subcategories poems

This commit is contained in:
Hamid Reza Mohammadi 2022-03-24 10:09:01 +04:30
parent 9e881628b1
commit 67c21dd056
3 changed files with 31 additions and 9 deletions

View File

@ -278,9 +278,12 @@
</td>
</tr>
<tr>
<td colspan="2">
<td>
<input type="submit" value="تغییر نام گروهی" />
</td>
<td>
<input type="submit" id="renameSubcats" name="renameSubcats" value="برای زیربخش‌ها" />
</td>
</tr>
</table>
</form>

View File

@ -160,18 +160,37 @@ namespace GanjooRazor.Areas.Admin.Pages
{
await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response);
HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/recaptionpoems/{Cat.Cat.Id}", new StringContent(JsonConvert.SerializeObject(NamingModel), Encoding.UTF8, "application/json"));
if (!response.IsSuccessStatusCode)
if (Request.Form["renameSubcats"].Count == 1)
{
LastMessage = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
foreach (var subCat in Cat.Cat.Children)
{
HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/recaptionpoems/{subCat.Id}", new StringContent(JsonConvert.SerializeObject(NamingModel), Encoding.UTF8, "application/json"));
if (!response.IsSuccessStatusCode)
{
LastMessage = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
return Page();
}
else
{
RenamingOutput = JsonConvert.DeserializeObject<string[]>(await response.Content.ReadAsStringAsync());
}
}
}
else
{
RenamingOutput = JsonConvert.DeserializeObject<string[]>(await response.Content.ReadAsStringAsync());
HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/recaptionpoems/{Cat.Cat.Id}", new StringContent(JsonConvert.SerializeObject(NamingModel), Encoding.UTF8, "application/json"));
if (!response.IsSuccessStatusCode)
{
LastMessage = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
return Page();
}
else
{
RenamingOutput = JsonConvert.DeserializeObject<string[]>(await response.Content.ReadAsStringAsync());
}
NamingModel.Simulate = false;
}
NamingModel.Simulate = false;
}
return Page();

View File

@ -8,8 +8,8 @@
},
"AllowedHosts": "*",
"GoogleAnalyticsCode": "",
"APIRoot": "http://localhost:3439",
"GlobalAPIRoot": "http://localhost:3439",
"APIRoot": "https://api.ganjoor.net",
"GlobalAPIRoot": "https://api.ganjoor.net",
"SiteUrl": "http://localhost:33081",
"MockSpotify": "False",
"Spotify": {