|
|
@ -1,40 +1,40 @@
|
|
|
|
using Blazor.Models;
|
|
|
|
using Blazor.Models;
|
|
|
|
using Blazor.Services;
|
|
|
|
using Blazor.Services;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Blazor.Pages.Chapters;
|
|
|
|
namespace Blazor.Pages.Chapters;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class EditChapter
|
|
|
|
public partial class EditChapter
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[Parameter]
|
|
|
|
[Parameter]
|
|
|
|
public int Id { get; set; }
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
private ChapterModel chapterModel = new();
|
|
|
|
private ChapterModel chapterModel = new();
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
|
public IDataService DataService { get; set; }
|
|
|
|
public IDataService DataService { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
|
public IWebHostEnvironment WebHostEnvironment { get; set; }
|
|
|
|
public IWebHostEnvironment WebHostEnvironment { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var chapter = await DataService.GetById(Id);
|
|
|
|
var chapter = await DataService.GetById(Id);
|
|
|
|
|
|
|
|
|
|
|
|
// Set the model with the chapter
|
|
|
|
// Set the model with the chapter
|
|
|
|
chapterModel = new ChapterModel
|
|
|
|
chapterModel = new ChapterModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = chapter.Id,
|
|
|
|
Id = chapter.Id,
|
|
|
|
Name = chapter.Name
|
|
|
|
Name = chapter.Name
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void HandleValidSubmit()
|
|
|
|
private async void HandleValidSubmit()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await DataService.Update(Id, chapterModel);
|
|
|
|
await DataService.Update(Id, chapterModel);
|
|
|
|
var formData = new List<KeyValuePair<string, string>>();
|
|
|
|
var formData = new List<KeyValuePair<string, string>>();
|
|
|
|
formData.Add(new KeyValuePair<string, string>("name", chapterModel.Name));
|
|
|
|
formData.Add(new KeyValuePair<string, string>("name", chapterModel.Name));
|
|
|
|
|
|
|
|
|
|
|
@ -55,7 +55,7 @@ public partial class EditChapter
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var errorResponse = await response.Content.ReadAsStringAsync();
|
|
|
|
var errorResponse = await response.Content.ReadAsStringAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NavigationManager.NavigateTo("chapters");
|
|
|
|
NavigationManager.NavigateTo("chapters");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|