Browse Source

Part 05 revision

pull/23128/head
Halil İbrahim Kalkan 1 year ago
parent
commit
6261d0db44
  1. BIN
      docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order-v2.png
  2. BIN
      docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order.png
  3. BIN
      docs/en/tutorials/modular-crm/images/sql-server-orders-database-table-v2.png
  4. BIN
      docs/en/tutorials/modular-crm/images/sql-server-orders-database-table.png
  5. BIN
      docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2-v2.png
  6. BIN
      docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2.png
  7. BIN
      docs/en/tutorials/modular-crm/images/visual-studio-order-entity-v2.png
  8. BIN
      docs/en/tutorials/modular-crm/images/visual-studio-order-entity.png
  9. 6
      docs/en/tutorials/modular-crm/part-03.md
  10. 25
      docs/en/tutorials/modular-crm/part-05.md

BIN
docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order-v2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
docs/en/tutorials/modular-crm/images/abp-studio-entity-framework-core-add-migration-order.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

BIN
docs/en/tutorials/modular-crm/images/sql-server-orders-database-table-v2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
docs/en/tutorials/modular-crm/images/sql-server-orders-database-table.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

BIN
docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2-v2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
docs/en/tutorials/modular-crm/images/visual-studio-new-migration-class-2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

BIN
docs/en/tutorials/modular-crm/images/visual-studio-order-entity-v2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
docs/en/tutorials/modular-crm/images/visual-studio-order-entity.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

6
docs/en/tutorials/modular-crm/part-03.md

@ -45,6 +45,8 @@ public class Product : AggregateRoot<Guid>
}
````
> Note that in this tutorial, we create classes directly in the project's root folder to keep things simple. It is up to you to create subfolders (namespaces) in your project to achieve finer code organization, especially for large modules.
## Mapping Entity to Database
The next step is to configure the Entity Framework Core `DbContext` class and the database for the new entity.
@ -182,13 +184,13 @@ public class ModularCrmDbContext :
}
````
**(3)** Finally, ensure that the `ConfigureCatalog()` extension method is called inside the `OnModelCreating` method (this should be already done because you set the _Setup as a modular solution_ option in the _Modularity_ step while creating the initial solution):
**(3)** Finally, ensure that the `ConfigureCatalog()` extension method is called inside the `OnModelCreating` method (this should be already done because you set the _Setup as a modular solution_ option in the _Modularity_ step while creating the initial solution).
In this way, `ModularCrmDbContext` can be used by the catalog module over the `ICatalogDbContext` interface. This part is only needed once for a module. Next time, you can directly add a new database migration, as explained in the next section.
#### Add a Database Migration
Now, you can add a new database migration. You can use Entity Framework Core's `Add-Migration` (or `dotnet ef migrations add`) terminal command, but we will use ABP Studio's shortcut UI in this tutorial.
You can use Entity Framework Core's `Add-Migration` (or `dotnet ef migrations add`) terminal command, but we will use ABP Studio's shortcut UI in this tutorial.
Ensure that the solution has built. You can right-click the `ModularCrm` (under the `main` folder) on ABP Studio *Solution Runner* and select the *Dotnet CLI* -> *Graph Build* command.

25
docs/en/tutorials/modular-crm/part-05.md

@ -14,7 +14,7 @@
}
````
In the previous part, you created Ordering module and installed it into the main application. However, the Ordering module has no functionality now. In this part, you will create an `Order` entity and add functionality to create and list the orders.
In the [previous part](part-04), you created Ordering module and installed it into the main application. However, the Ordering module has no functionality yet. In this part, you will create an `Order` entity and add functionality to create and list the orders.
## Creating an `Order` Entity
@ -24,14 +24,13 @@ Open the `ModularCrm.Ordering` .NET solution in your IDE.
### Adding an `Order` Class
Create an `Order` class to the `ModularCrm.Ordering` project (open an `Entities` folder and place the `Order.cs` into that folder):
Create an `Order` class to the `ModularCrm.Ordering` project:
````csharp
using System;
using ModularCrm.Ordering.Contracts.Enums;
using Volo.Abp.Domain.Entities.Auditing;
namespace ModularCrm.Ordering.Entities;
namespace ModularCrm.Ordering;
public class Order : CreationAuditedAggregateRoot<Guid>
{
@ -41,14 +40,14 @@ public class Order : CreationAuditedAggregateRoot<Guid>
}
````
We allow users to place only a single product within an order. The `Order` entity would be much more complex in a real-world application. However, the complexity of the `Order` entity doesn't affect modularity, so we keep it simple to focus on modularity in this tutorial. We are inheriting from the [`CreationAuditedAggregateRoot` class](../../framework/architecture/domain-driven-design/entities.md) since I want to know when an order has been created and who has created it.
We allow users to place only a single product within an order. The `Order` entity would be much more complex in a real-world application. However, the complexity of the `Order` entity doesn't affect modularity. So, we keep it simple to focus on modularity in this tutorial. We are inheriting from the [`CreationAuditedAggregateRoot` class](../../framework/architecture/domain-driven-design/entities.md) since I want to know when an order has been created and who has created it.
### Adding an `OrderState` Enumeration
You used an `OrderState` enumeration that has not yet been defined. Open an `Enums` folder in the `ModularCrm.Ordering.Contracts` project and create an `OrderState.cs` file inside it:
We used an `OrderState` enumeration that has not yet been defined. Create a `OrderState.cs` file inside the `ModularCrm.Ordering.Contracts` project and define the following Enum:
````csharp
namespace ModularCrm.Ordering.Contracts.Enums;
namespace ModularCrm.Ordering;
public enum OrderState : byte
{
@ -60,7 +59,7 @@ public enum OrderState : byte
The final structure of the Ordering module should be similar to the following figure in your IDE:
![visual-studio-order-entity](images/visual-studio-order-entity.png)
![visual-studio-order-entity](images/visual-studio-order-entity-v2.png)
## Configuring the Database Mapping
@ -202,19 +201,21 @@ Right-click the `ModularCrm` package and select the *EF Core CLI* -> *Add Migrat
The *Add Migration* command opens a new dialog to get a migration name:
![abp-studio-entity-framework-core-add-migration-order](images/abp-studio-entity-framework-core-add-migration-order.png)
![abp-studio-entity-framework-core-add-migration-order](images/abp-studio-entity-framework-core-add-migration-order-v2.png)
Once you click the *OK* button, a new database migration class is added to the `Migrations` folder of the `ModularCrm` project:
![visual-studio-new-migration-class-2](images/visual-studio-new-migration-class-2.png)
![visual-studio-new-migration-class-2](images/visual-studio-new-migration-class-2-v2.png)
Now, you can return to ABP Studio, right-click the `ModularCrm` project and select the *EF Core CLI* -> *Update Database* command:
![abp-studio-entity-framework-core-update-database](images/abp-studio-entity-framework-core-update-database.png)
After the operation completes, you can check your database to see the new `Orders` table has been created:
After the operation completes, you can check your database to see the new `OrderingOrders` table has been created:
![sql-server-products-database-table](images/sql-server-orders-database-table-v2.png)
![sql-server-products-database-table](images/sql-server-orders-database-table.png)
`Ordering` prefix is added to all table names of the Ordering module. If you want to change or remove it, see the `OrderingDbProperties` class in the Ordering module's .NET solution.
## Creating the Application Service

Loading…
Cancel
Save