Creating the Initial Ordering Module

In this part, you will build a new module for placing orders and install it to the main CRM application.

Creating an Empty Module

We have used the DDD Module template for the Product module. We will use the Empty Module template for the Ordering module in this part.

Right-click the modules folder on the Solution Explorer panel, and select the Add -> New Module -> Empty Module command:

abp-studio-add-new-empty-module

That command opens a dialog to define the properties of the new module:

abp-studio-add-new-empty-module-dialog

Set ModularCrm.Ordering as the Module name, leave the Output folder as is and click the Create button. It will create the new ModularCrm.Ordering module under the modules folder in the Solution Explorer:

abp-studio-modular-crm-with-two-modules

Since we've created an empty module, it is really empty. If you open the modules/modularcrm.ordering in your file system, you can see the initial files:

file-system-odering-module-initial-folder

Creating the Module Packages

In this section, we will create packages under the Ordering module. The Products module was well layered based on Domain Driven Design principles. This time, we will keep the things very simple and will only create two packaged for the Ordering module:

  • ModularCrm.Ordering: Contains all the module code without any layering. It will contains entities, database access code, services, controllers, UI pages and whatever we need to implement the Ordering module.
  • ModularCrm.Ordering.Contracts: Contains the services and objects we want to share with other modules. ModularCrm.Ordering uses (and implements) this package.

If your modules are relatively small, easy to maintain, they will only be used by your main application and you don't care about layering, you can create such simple module structures.

We will create and configure everything from scratch. You have already learned the easy way in the previous parts where we've created the Products module. It is time to have a deep understanding of the details and learn how ABP Studio allows you to setup custom structures. Let's begin...

Creating the ModularCrm.Ordering.Contracts Package

We will start by creating the ModularCrm.Ordering.Contracts package. Right-click the ModularCrm.Ordering module on the Solution Explorer and select the Add -> Package -> New Package command as shown in the following figure:

abp-studio-add-new-package

That command opens a new dialog to create a new package:

abp-studio-add-new-package-class-library

With that dialog, you can build your module or application layer by layer. There are templates for any type of package. However, here we will go with the most simple one: ABP Class Library. ABP Class Library is an empty C# class library with the core ABP package dependency and a module class.

Type ModularCrm.Ordering.Contracts as the Package name and click the Create button. It will add the package under the ModularCrm.Ordering module:

abp-studio-new-package-under-the-module

Creating the ModularCrm.Ordering Package

Right-click the ModularCrm.Ordering module on the Solution Explorer again and select the Add -> Package -> New Package command to create a second package:

abp-studio-add-new-package-mvc-ui

This time, we are selecting the MVC UI template and set the Package name as ModularCrm.Ordering. Click the Create button to add the new package.

Add Package Reference

After the package has been added, right-click the ModularCrm.Ordering package and select the Add Package Reference command:

abp-studio-add-package-reference

That command opens a dialog to select the package:

abp-studio-add-package-reference-dialog

In that dialog, you can add package reference from various sources. Here, we will add reference for the package in the current module. So, select the ModularCrm.Ordering.Contracts package in This module tab and click the OK button. You can see the package reference under the Projects dependencies on the Solution Explorer panel:

abp-studio-project-reference-example

The initial module creation has been completed. Now, we have a new module with 2 packages. However, it has no relation to other modules and applications in the solution yet.

Installing into the Main Application

In this section, we will install the ModularCrm.Ordering module to the main application, so it can be a part of the system.

Before the installation, ensure that the web application is not running.

Right-click the ModularCrm module (under the main folder) and select the Import Module command:

abp-studio-import-module-for-ordering

That command opens the Import Module dialog:

abp-studio-import-module-for-ordering-dialog

Select the ModularCrm.Ordering module and check the Install this module option as shown in the preceding figure. When you click the OK button, a new dialog is shown to select the packages to install:

abp-studio-install-module-dialog

Select the ModuleCrm.Ordering package on the left area, ModularCrm.Domain package on the middle area as shown in the preceding figure and click the OK button.

Since the Ordering module is not layered, we didn't install its packages to the layers of our main application. We are installing it only to ModularCrm.Domain. In this way, we can use the Ordering module from any layer of our application since ModularCrm.Domain is one of the core packages of our application. If you build your modules as non-layered and you don't have much code in the main application's .NET solution, you can also consider to create a non-layered main application that composes these modules.

In this part of the tutorial, we've created an empty module and added packages. In that way, you can create modules or applications with custom structure. In the next part, we will add functionality to the Ordering module.


Contributors


Last updated: September 06, 2024 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

In this document
Community Talks

ABP Studio: The Missing Tool for .NET Developers

15 Aug, 17:00
Online
Watch the Event
Mastering ABP Framework Book
Mastering ABP Framework

This book will help you gain a complete understanding of the framework and modern web application development techniques.

Learn More