Skip to content

Commit

Permalink
Merge pull request #68 from abpio/feat/4022
Browse files Browse the repository at this point in the history
Update the Blazor tutorial for ABP 4.0
  • Loading branch information
ismcagdas authored Dec 2, 2020
2 parents b722ed5 + c96a3a7 commit 79c23b5
Show file tree
Hide file tree
Showing 8 changed files with 338 additions and 328 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions en/tutorials/book-store/part-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ namespace Acme.BookStore
{
public BookStoreApplicationAutoMapperProfile()
{
CreateMap<AppUser, AppUserDto>().Ignore(x => x.ExtraProperties);

CreateMap<Book, BookDto>();
}
}
Expand Down Expand Up @@ -370,6 +372,8 @@ namespace Acme.BookStore
{
public BookStoreApplicationAutoMapperProfile()
{
CreateMap<AppUser, AppUserDto>().Ignore(x => x.ExtraProperties);

CreateMap<Book, BookDto>();
CreateMap<CreateUpdateBookDto, Book>();
}
Expand Down
37 changes: 21 additions & 16 deletions en/tutorials/book-store/part-10.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Guid AuthorId { get; set; }

{{if DB=="EF"}}

> In this tutorial, we preferred to not add a **navigation property** to the `Author` entity from the `Book` class (like `public Author Author { get; set; }`). This is due to follow the DDD best practices (rule: refer to other aggregates only by id). However, you can add such a navigation property and configure it for the EF Core. In this way, you don't need to write join queries while getting books with their authors (just like we will done below) which makes your application code simpler.
> In this tutorial, we preferred to not add a **navigation property** to the `Author` entity from the `Book` class (like `public Author Author { get; set; }`). This is due to follow the DDD best practices (rule: refer to other aggregates only by id). However, you can add such a navigation property and configure it for the EF Core. In this way, you don't need to write join queries while getting books with their authors (like we will done below) which makes your application code simpler.
{{end}}

Expand Down Expand Up @@ -362,7 +362,7 @@ namespace Acme.BookStore.Books
DeletePolicyName = BookStorePermissions.Books.Create;
}

public async override Task<BookDto> GetAsync(Guid id)
public override async Task<BookDto> GetAsync(Guid id)
{
//Prepare a query to join books and authors
var query = from book in Repository
Expand All @@ -382,7 +382,7 @@ namespace Acme.BookStore.Books
return bookDto;
}

public async override Task<PagedResultDto<BookDto>>
public override async Task<PagedResultDto<BookDto>>
GetListAsync(PagedAndSortedResultRequestDto input)
{
//Prepare a query to join books and authors
Expand Down Expand Up @@ -1070,32 +1070,37 @@ Add the following field to the `@code` section of the `Books.razor` file:
IReadOnlyList<AuthorLookupDto> authorList = Array.Empty<AuthorLookupDto>();
````

And fill it in the `OnInitializedAsync` method, by adding the following code to the end of the method:
Override the `OnInitializedAsync` method and add the following code to the end of the method:

````csharp
authorList = (await AppService.GetAuthorLookupAsync()).Items;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
authorList = (await AppService.GetAuthorLookupAsync()).Items;
}
````

\* It is essential to call the `base.OnInitializedAsync()` since `AbpCrudPageBase` has some initialization code to be executed.

The final `@code` block should be the following:

````csharp
@code
{
bool canCreateBook;
bool canEditBook;
bool canDeleteBook;
//ADDED A NEW FIELD
IReadOnlyList<AuthorLookupDto> authorList = Array.Empty<AuthorLookupDto>();
protected async override Task OnInitializedAsync()

public Books() // Constructor
{
CreatePolicyName = BookStorePermissions.Books.Create;
UpdatePolicyName = BookStorePermissions.Books.Edit;
DeletePolicyName = BookStorePermissions.Books.Delete;
}

//GET AUTHORS ON INITIALIZATION
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
canCreateBook = await
AuthorizationService.IsGrantedAsync(BookStorePermissions.Books.Create);
canEditBook = await
AuthorizationService.IsGrantedAsync(BookStorePermissions.Books.Edit);
canDeleteBook = await
AuthorizationService.IsGrantedAsync(BookStorePermissions.Books.Delete);
//GET AUTHORS
authorList = (await AppService.GetAuthorLookupAsync()).Items;
}
}
Expand Down
10 changes: 9 additions & 1 deletion en/tutorials/book-store/part-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ Open the `en.json` (*the English translations*) file and change the content as b
"Permission:Dashboard": "Dashboard",
"Menu:Dashboard": "Dashboard",
"Dashboard": "Dashboard",
"ExternalProvider:Google":"Google",
"ExternalProvider:Google:ClientId":"Client ID",
"ExternalProvider:Google:ClientSecret":"Client Secret",
"ExternalProvider:Microsoft":"Microsoft",
"ExternalProvider:Microsoft:ClientId":"Client ID",
"ExternalProvider:Microsoft:ClientSecret":"Client Secret",
"ExternalProvider:Twitter":"Twitter",
"ExternalProvider:Twitter:ConsumerKey":"Consumer Key",
"ExternalProvider:Twitter:ConsumerSecret":"Consumer Secret",
"Menu:BookStore": "Book Store",
"Menu:Books": "Books",
"Actions": "Actions",
Expand Down Expand Up @@ -607,7 +616,6 @@ Open the `Books.razor` and replace the content as the following:
````xml
@page "/books"
@using Volo.Abp.Application.Dtos
@using Volo.Abp.BlazoriseUI
@using Acme.BookStore.Books
@using Acme.BookStore.Localization
@using Microsoft.Extensions.Localization
Expand Down
Loading

0 comments on commit 79c23b5

Please sign in to comment.