Browse Source

Improve bookstore tutorial according to the feedback

pull/21545/head
liangshiwei 1 year ago
parent
commit
613fea3f5c
  1. 12
      docs/en/tutorials/book-store/part-02.md
  2. 11
      docs/en/tutorials/book-store/part-03.md
  3. 28
      docs/en/tutorials/book-store/part-05.md
  4. 2
      docs/en/tutorials/book-store/part-06.md
  5. 7
      docs/en/tutorials/book-store/part-09.md
  6. 2
      docs/en/tutorials/book-store/part-10.md

12
docs/en/tutorials/book-store/part-02.md

@ -577,8 +577,6 @@ Open the `Books.razor` and replace the content as the following:
@using Volo.Abp.Application.Dtos
@using Acme.BookStore.Books
@using Acme.BookStore.Localization
@using Microsoft.Extensions.Localization
@inject IStringLocalizer<BookStoreResource> L
@inherits AbpCrudPageBase<IBookAppService, BookDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateBookDto>
<Card>
@ -625,13 +623,21 @@ Open the `Books.razor` and replace the content as the following:
</DataGrid>
</CardBody>
</Card>
@code
{
public Books() // Constructor
{
LocalizationResource = typeof(BookStoreResource);
}
}
````
> If you see some syntax errors, you can ignore them if your application is properly built and running. Visual Studio still has some bugs with Blazor.
* Inherited from `AbpCrudPageBase<IBookAppService, BookDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateBookDto>` which implements all the CRUD details for us.
* `Entities`, `TotalCount`, `PageSize`, `OnDataGridReadAsync` are defined in the base class.
* Injected `IStringLocalizer<BookStoreResource>` (as `L` object) and used for localization.
* `LocalizationResource` is set to the `BookStoreResource` to localize the texts.
While the code above is pretty easy to understand, you can check the Blazorise [Card](https://blazorise.com/docs/components/card/) and [DataGrid](https://blazorise.com/docs/extensions/datagrid/) documents to understand them better.

11
docs/en/tutorials/book-store/part-03.md

@ -1351,7 +1351,6 @@ Here's the complete code to create the book management CRUD page, that has been
@using Acme.BookStore.Localization
@using Microsoft.Extensions.Localization
@using Volo.Abp.AspNetCore.Components.Web
@inject IStringLocalizer<BookStoreResource> L
@inject AbpBlazorMessageLocalizerHelper<BookStoreResource> LH
@inherits AbpCrudPageBase<IBookAppService, BookDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateBookDto>
@ -1396,7 +1395,7 @@ Here's the complete code to create the book management CRUD page, that has been
Field="@nameof(BookDto.Type)"
Caption="@L["Type"]">
<DisplayTemplate>
@L[$"Enum:BookType.{context.Type}"]
@L[$"Enum:BookType.{context.Type:D}"]
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="BookDto"
@ -1527,6 +1526,14 @@ Here's the complete code to create the book management CRUD page, that has been
</Form>
</ModalContent>
</Modal>
@code
{
public Books() // Constructor
{
LocalizationResource = typeof(BookStoreResource);
}
}
````
{{end}}

28
docs/en/tutorials/book-store/part-05.md

@ -420,6 +420,8 @@ Add the following code block to the end of the `Books.razor` file:
{
public Books() // Constructor
{
LocalizationResource = typeof(BookStoreResource);
CreatePolicyName = BookStorePermissions.Books.Create;
UpdatePolicyName = BookStorePermissions.Books.Edit;
DeletePolicyName = BookStorePermissions.Books.Delete;
@ -509,14 +511,11 @@ var bookStoreMenu = new ApplicationMenuItem(
context.Menu.AddItem(bookStoreMenu);
//CHECK the PERMISSION
if (await context.IsGrantedAsync(BookStorePermissions.Books.Default))
{
bookStoreMenu.AddItem(new ApplicationMenuItem(
"BooksStore.Books",
l["Menu:Books"],
url: "/books"
));
}
bookStoreMenu.AddItem(new ApplicationMenuItem(
"BooksStore.Books",
l["Menu:Books"],
url: "/books"
).RequirePermissions(BookStorePermissions.Books.Default));
````
You also need to add `async` keyword to the `ConfigureMenuAsync` method and re-arrange the return value. The final `ConfigureMainMenuAsync` method should be the following:
@ -545,14 +544,11 @@ private async Task ConfigureMainMenuAsync(MenuConfigurationContext context)
context.Menu.AddItem(bookStoreMenu);
//CHECK the PERMISSION
if (await context.IsGrantedAsync(BookStorePermissions.Books.Default))
{
bookStoreMenu.AddItem(new ApplicationMenuItem(
"BooksStore.Books",
l["Menu:Books"],
url: "/books"
));
}
bookStoreMenu.AddItem(new ApplicationMenuItem(
"BooksStore.Books",
l["Menu:Books"],
url: "/books"
).RequirePermissions(BookStorePermissions.Books.Default));
}
````

2
docs/en/tutorials/book-store/part-06.md

@ -41,7 +41,6 @@ Create an `Authors` folder (namespace) in the `Acme.BookStore.Domain` project an
````csharp
using System;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
@ -115,7 +114,6 @@ Created this class inside the `Acme.BookStore.Domain.Shared` project since we wi
````csharp
using System;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Services;

7
docs/en/tutorials/book-store/part-09.md

@ -1214,14 +1214,11 @@ You will need to declare a `using Acme.BookStore.Authors;` statement to the begi
Open the `BookStoreMenuContributor.cs` in the {{ if UI == "BlazorServer" }}`Acme.BookStore.Blazor`{{ else }}`Acme.BookStore.Blazor.Client`{{ end }} project and add the following code to the end of the `ConfigureMainMenuAsync` method:
````csharp
if (await context.IsGrantedAsync(BookStorePermissions.Authors.Default))
{
context.Menu.AddItem(new ApplicationMenuItem(
context.Menu.AddItem(new ApplicationMenuItem(
"BooksStore.Authors",
l["Menu:Authors"],
url: "/authors"
));
}
).RequirePermissions(BookStorePermissions.Books.Default));
````
### Localizations

2
docs/en/tutorials/book-store/part-10.md

@ -1132,6 +1132,8 @@ The final `@code` block should be the following:
public Books() // Constructor
{
LocalizationResource = typeof(BookStoreResource);
CreatePolicyName = BookStorePermissions.Books.Create;
UpdatePolicyName = BookStorePermissions.Books.Edit;
DeletePolicyName = BookStorePermissions.Books.Delete;

Loading…
Cancel
Save