diff --git a/docs/en/Tutorials/Angular/Part-I.md b/docs/en/Tutorials/Angular/Part-I.md index fdc8de4bf4..06ba6aa41d 100644 --- a/docs/en/Tutorials/Angular/Part-I.md +++ b/docs/en/Tutorials/Angular/Part-I.md @@ -246,7 +246,7 @@ using Volo.Abp.Application.Services; namespace Acme.BookStore { public interface IBookAppService : - IAsyncCrudAppService< //Defines CRUD methods + ICrudAppService< //Defines CRUD methods BookDto, //Used to show books Guid, //Primary key of the book entity PagedAndSortedResultRequestDto, //Used for paging/sorting on getting a list of books @@ -259,8 +259,8 @@ namespace Acme.BookStore ``` - Defining interfaces for application services is not required by the framework. However, it's suggested as a best practice. -- `IAsyncCrudAppService` defines common **CRUD** methods: `GetAsync`, `GetListAsync`, `CreateAsync`, `UpdateAsync` and `DeleteAsync`. It's not required to extend it. Instead, you could inherit from the empty `IApplicationService` interface and define your own methods manually. -- There are some variations of the `IAsyncCrudAppService` where you can use separated DTOs for each method. +- `ICrudAppService` defines common **CRUD** methods: `GetAsync`, `GetListAsync`, `CreateAsync`, `UpdateAsync` and `DeleteAsync`. It's not required to extend it. Instead, you could inherit from the empty `IApplicationService` interface and define your own methods manually. +- There are some variations of the `ICrudAppService` where you can use separated DTOs for each method. #### BookAppService @@ -275,7 +275,7 @@ using Volo.Abp.Domain.Repositories; namespace Acme.BookStore { public class BookAppService : - AsyncCrudAppService, IBookAppService { @@ -288,7 +288,7 @@ namespace Acme.BookStore } ``` -- `BookAppService` is derived from `AsyncCrudAppService<...>` which implements all the CRUD methods defined above. +- `BookAppService` is derived from `CrudAppService<...>` which implements all the CRUD methods defined above. - `BookAppService` injects `IRepository` which is the default repository for the `Book` entity. ABP automatically creates default repositories for each aggregate root (or entity). See the [repository document](../../Repositories.md). - `BookAppService` uses `IObjectMapper` to convert `Book` objects to `BookDto` objects and `CreateUpdateBookDto` objects to `Book` objects. The Startup template uses the [AutoMapper](http://automapper.org/) library as the object mapping provider. You defined the mappings before, so it will work as expected. @@ -298,10 +298,14 @@ You normally create **Controllers** to expose application services as **HTTP API #### Swagger UI -The startup template is configured to run the [swagger UI](https://swagger.io/tools/swagger-ui/) using the [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) library. Run the application and enter `https://localhost:XXXX/swagger/` (replace XXXX by your own port) as URL on your browser. +The startup template is configured to run the [swagger UI](https://swagger.io/tools/swagger-ui/) using the [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) library. Run the `Acme.BookStore.HttpApi.Host` application and enter `https://localhost:XXXX/swagger/` (replace XXXX by your own port) as URL on your browser. You will see some built-in service endpoints as well as the `Book` service and its REST-style endpoints: -TODO: Screenshot +![bookstore-swagger](images/bookstore-swagger-api.png) -Swagger has a nice UI to test APIs. You can try to execute the `[GET] /api/app/book` API to get a list of books. \ No newline at end of file +Swagger has a nice UI to test APIs. You can try to execute the `[GET] /api/app/book` API to get a list of books. + +### Create the Books Page + +It's time to create something visible and usable! \ No newline at end of file diff --git a/docs/en/Tutorials/Angular/images/bookstore-swagger-api.png b/docs/en/Tutorials/Angular/images/bookstore-swagger-api.png new file mode 100644 index 0000000000..437c772503 Binary files /dev/null and b/docs/en/Tutorials/Angular/images/bookstore-swagger-api.png differ diff --git a/docs/en/Tutorials/AspNetCore-Mvc/Part-I.md b/docs/en/Tutorials/AspNetCore-Mvc/Part-I.md index dfdc27fa53..ca4daaadfe 100644 --- a/docs/en/Tutorials/AspNetCore-Mvc/Part-I.md +++ b/docs/en/Tutorials/AspNetCore-Mvc/Part-I.md @@ -221,7 +221,7 @@ using Volo.Abp.Application.Services; namespace Acme.BookStore { public interface IBookAppService : - IAsyncCrudAppService< //Defines CRUD methods + ICrudAppService< //Defines CRUD methods BookDto, //Used to show books Guid, //Primary key of the book entity PagedAndSortedResultRequestDto, //Used for paging/sorting on getting a list of books @@ -234,8 +234,8 @@ namespace Acme.BookStore ```` * Defining interfaces for application services is not required by the framework. However, it's suggested as a best practice. -* `IAsyncCrudAppService` defines common **CRUD** methods: `GetAsync`, `GetListAsync`, `CreateAsync`, `UpdateAsync` and `DeleteAsync`. It's not required to extend it. Instead, you could inherit from the empty `IApplicationService` interface and define your own methods manually. -* There are some variations of the `IAsyncCrudAppService` where you can use separated DTOs for each method. +* `ICrudAppService` defines common **CRUD** methods: `GetAsync`, `GetListAsync`, `CreateAsync`, `UpdateAsync` and `DeleteAsync`. It's not required to extend it. Instead, you could inherit from the empty `IApplicationService` interface and define your own methods manually. +* There are some variations of the `ICrudAppService` where you can use separated DTOs for each method. #### BookAppService @@ -250,8 +250,8 @@ using Volo.Abp.Domain.Repositories; namespace Acme.BookStore { public class BookAppService : - AsyncCrudAppService, + CrudAppService, IBookAppService { public BookAppService(IRepository repository) @@ -263,7 +263,7 @@ namespace Acme.BookStore } ```` -* `BookAppService` is derived from `AsyncCrudAppService<...>` which implements all the CRUD methods defined above. +* `BookAppService` is derived from `CrudAppService<...>` which implements all the CRUD methods defined above. * `BookAppService` injects `IRepository` which is the default repository for the `Book` entity. ABP automatically creates default repositories for each aggregate root (or entity). See the [repository document](../../Repositories.md). * `BookAppService` uses `IObjectMapper` to convert `Book` objects to `BookDto` objects and `CreateUpdateBookDto` objects to `Book` objects. The Startup template uses the [AutoMapper](http://automapper.org/) library as the object mapping provider. You defined the mappings before, so it will work as expected. diff --git a/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application.Contracts/BookDto.cs b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application.Contracts/BookDto.cs new file mode 100644 index 0000000000..5a94fbce1e --- /dev/null +++ b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application.Contracts/BookDto.cs @@ -0,0 +1,16 @@ +using System; +using Volo.Abp.Application.Dtos; + +namespace Acme.BookStore +{ + public class BookDto : AuditedEntityDto + { + public string Name { get; set; } + + public BookType Type { get; set; } + + public DateTime PublishDate { get; set; } + + public float Price { get; set; } + } +} \ No newline at end of file diff --git a/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application.Contracts/CreateUpdateBookDto.cs b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application.Contracts/CreateUpdateBookDto.cs new file mode 100644 index 0000000000..8dc38a9e31 --- /dev/null +++ b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application.Contracts/CreateUpdateBookDto.cs @@ -0,0 +1,21 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace Acme.BookStore +{ + public class CreateUpdateBookDto + { + [Required] + [StringLength(128)] + public string Name { get; set; } + + [Required] + public BookType Type { get; set; } = BookType.Undefined; + + [Required] + public DateTime PublishDate { get; set; } + + [Required] + public float Price { get; set; } + } +} \ No newline at end of file diff --git a/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application.Contracts/IBookAppService.cs b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application.Contracts/IBookAppService.cs new file mode 100644 index 0000000000..5a17a8f19d --- /dev/null +++ b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application.Contracts/IBookAppService.cs @@ -0,0 +1,17 @@ +using System; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace Acme.BookStore +{ + public interface IBookAppService : + ICrudAppService< //Defines CRUD methods + BookDto, //Used to show books + Guid, //Primary key of the book entity + PagedAndSortedResultRequestDto, //Used for paging/sorting on getting a list of books + CreateUpdateBookDto, //Used to create a new book + CreateUpdateBookDto> //Used to update a book + { + + } +} \ No newline at end of file diff --git a/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application/BookAppService.cs b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application/BookAppService.cs new file mode 100644 index 0000000000..8d9d29468a --- /dev/null +++ b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application/BookAppService.cs @@ -0,0 +1,19 @@ +using System; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; + +namespace Acme.BookStore +{ + public class BookAppService : + CrudAppService, + IBookAppService + { + public BookAppService(IRepository repository) + : base(repository) + { + + } + } +} \ No newline at end of file diff --git a/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application/BookStoreApplicationAutoMapperProfile.cs b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application/BookStoreApplicationAutoMapperProfile.cs index 0706d83633..9bc08930cf 100644 --- a/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application/BookStoreApplicationAutoMapperProfile.cs +++ b/samples/BookStore-Angular-MongoDb/aspnet-core/src/Acme.BookStore.Application/BookStoreApplicationAutoMapperProfile.cs @@ -6,9 +6,8 @@ namespace Acme.BookStore { public BookStoreApplicationAutoMapperProfile() { - /* You can configure your AutoMapper mapping configuration here. - * Alternatively, you can split your mapping configurations - * into multiple profile classes for a better organization. */ + CreateMap(); + CreateMap(); } } }