diff --git a/docs/en/tutorials/book-store/part-02.md b/docs/en/tutorials/book-store/part-02.md index bb812e7d81..3ff19437cd 100644 --- a/docs/en/tutorials/book-store/part-02.md +++ b/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 L @inherits AbpCrudPageBase @@ -625,13 +623,21 @@ Open the `Books.razor` and replace the content as the following: + +@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` which implements all the CRUD details for us. * `Entities`, `TotalCount`, `PageSize`, `OnDataGridReadAsync` are defined in the base class. -* Injected `IStringLocalizer` (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. diff --git a/docs/en/tutorials/book-store/part-03.md b/docs/en/tutorials/book-store/part-03.md index 65f6d482dd..fc4e851b94 100644 --- a/docs/en/tutorials/book-store/part-03.md +++ b/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 L @inject AbpBlazorMessageLocalizerHelper LH @inherits AbpCrudPageBase @@ -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"]"> - @L[$"Enum:BookType.{context.Type}"] + @L[$"Enum:BookType.{context.Type:D}"] + +@code +{ + public Books() // Constructor + { + LocalizationResource = typeof(BookStoreResource); + } +} ```` {{end}} diff --git a/docs/en/tutorials/book-store/part-05.md b/docs/en/tutorials/book-store/part-05.md index 95ee1f53a6..d4815c5a96 100644 --- a/docs/en/tutorials/book-store/part-05.md +++ b/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)); } ```` diff --git a/docs/en/tutorials/book-store/part-06.md b/docs/en/tutorials/book-store/part-06.md index 58a83cfc16..05e1d04460 100644 --- a/docs/en/tutorials/book-store/part-06.md +++ b/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; diff --git a/docs/en/tutorials/book-store/part-09.md b/docs/en/tutorials/book-store/part-09.md index 3c1b0cb7d5..d481dbe92e 100644 --- a/docs/en/tutorials/book-store/part-09.md +++ b/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 diff --git a/docs/en/tutorials/book-store/part-10.md b/docs/en/tutorials/book-store/part-10.md index 928881ffec..c4383aa5c9 100644 --- a/docs/en/tutorials/book-store/part-10.md +++ b/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;