|
|
|
@ -23,9 +23,12 @@ public partial class EditChapter
|
|
|
|
|
[Inject]
|
|
|
|
|
public ILogger<EditChapter> Logger { get; set; }
|
|
|
|
|
|
|
|
|
|
private string oldChapterName { get; set; }
|
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
var chapter = await DataService.GetById(Id);
|
|
|
|
|
oldChapterName = chapter.Name;
|
|
|
|
|
|
|
|
|
|
// Set the model with the chapter
|
|
|
|
|
chapterModel = new ChapterModel
|
|
|
|
@ -38,6 +41,7 @@ public partial class EditChapter
|
|
|
|
|
private async void HandleValidSubmit()
|
|
|
|
|
{
|
|
|
|
|
await DataService.Update(Id, chapterModel);
|
|
|
|
|
|
|
|
|
|
var formData = new List<KeyValuePair<string, string>>();
|
|
|
|
|
formData.Add(new KeyValuePair<string, string>("name", chapterModel.Name));
|
|
|
|
|
|
|
|
|
@ -51,7 +55,7 @@ public partial class EditChapter
|
|
|
|
|
var response = await httpClient.PostAsync(apiUri, formContent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.LogInformation("Chapter '{chapterModelName}' edited", chapterModel.Name);
|
|
|
|
|
Logger.LogInformation("Chapter '{OldChapterModelName}' edited in '{NewChapterModelName}'",oldChapterName,chapterModel.Name);
|
|
|
|
|
|
|
|
|
|
if (response.IsSuccessStatusCode)
|
|
|
|
|
{
|
|
|
|
|