Browse Source

Update Part-10.md

pull/15507/head
Onur Pıçakcı 3 years ago
parent
commit
aa7c19843d
  1. 29
      docs/en/Tutorials/Part-10.md

29
docs/en/Tutorials/Part-10.md

@ -1126,6 +1126,21 @@ protected override async Task OnInitializedAsync()
* It is essential to call the `base.OnInitializedAsync()` since `AbpCrudPageBase` has some initialization code to be executed.
Override the `OpenCreateModalAsync` method and adding the following code:
````csharp
protected override async Task OpenCreateModalAsync()
{
if (!authorList.Any())
{
throw new UserFriendlyException(message: L["AnAuthorIsRequiredForCreatingBook"]);
}
await base.OpenCreateModalAsync();
NewEntity.AuthorId = authorList.First().Id;
}
````
The final `@code` block should be the following:
````csharp
@ -1147,6 +1162,17 @@ The final `@code` block should be the following:
await base.OnInitializedAsync();
authorList = (await AppService.GetAuthorLookupAsync()).Items;
}
protected override async Task OpenCreateModalAsync()
{
if (!authorList.Any())
{
throw new UserFriendlyException(message: L["AnAuthorIsRequiredForCreatingBook"]);
}
await base.OpenCreateModalAsync();
NewEntity.AuthorId = authorList.First().Id;
}
}
````
@ -1156,7 +1182,6 @@ Finally, add the following `Field` definition into the `ModalBody` of the *Creat
<Field>
<FieldLabel>@L["Author"]</FieldLabel>
<Select TValue="Guid" @bind-SelectedValue="@NewEntity.AuthorId">
<SelectItem TValue="Guid" Value="Guid.Empty">@L["PickAnAuthor"]</SelectItem>
@foreach (var author in authorList)
{
<SelectItem TValue="Guid" Value="@author.Id">
@ -1170,7 +1195,7 @@ Finally, add the following `Field` definition into the `ModalBody` of the *Creat
This requires to add a new localization key to the `en.json` file:
````js
"PickAnAuthor": "Pick an author"
"AnAuthorIsRequiredForCreatingBook": "An author is required to create a book"
````
You can run the application to see the *Author Selection* while creating a new book:

Loading…
Cancel
Save