docs: #302 transfering a category to its more complete alternative

This commit is contained in:
Hamid Reza Mohammadi 2022-03-29 11:34:39 +04:30
parent c734ce9f5d
commit d5c7db23e0
3 changed files with 42 additions and 0 deletions

View File

@ -47,5 +47,17 @@ else
</td>
</tr>
</table>
<table>
<tr>
<td>نهایی سازی انتقال به بخش:</td>
<td>
<form method="post" action="/Admin/CatTrans?Handler=Finalize&id=@Model.CatId">
<input asp-for="DestCatId" />
<input type="submit" value="نهایی سازی" />
</form>
</td>
</tr>
</table>
}

View File

@ -106,6 +106,33 @@ namespace GanjooRazor.Areas.Admin.Pages
}
}
}
public async Task<IActionResult> OnPostFinalizeAsync()
{
CatId = int.Parse(Request.Query["id"]);
using (HttpClient secureClient = new HttpClient())
{
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
{
HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/duplicates/finish/{CatId}/{DestCatId}", null);
if (!response.IsSuccessStatusCode)
{
LastMessage = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
return Page();
}
else
{
LastMessage = "فرایند شروع شد.";
return Page();
}
}
else
{
LastMessage = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
return Page();
}
}
}
}
}

View File

@ -139,6 +139,9 @@ namespace RMuseum.Services.Implementation
context.Update(destCatPage);
context.Remove(catPage);
var cat = await context.GanjoorCategories.Where(c => c.Id == catId).SingleAsync();
context.Remove(cat);
await jobProgressServiceEF.UpdateJob(job.Id, 100, "", true);
}
catch (Exception exp)