diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index fa724bb906..1446c0365b 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -1,24 +1,24 @@ -name: Merge branch rel-4.0 with rel-3.3 +name: Merge branch rel-4.1 with rel-4.0 on: push: branches: - - rel-3.3 + - rel-4.0 jobs: - merge-rel-4-0-with-rel-3-3: + merge-rel-4-1-with-rel-4-0: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: - ref: rel-4.0 + ref: rel-4.1 - name: Reset promotion branch run: | - git fetch origin rel-3.3:rel-3.3 - git reset --hard rel-3.3 + git fetch origin rel-4.0:rel-4.0 + git reset --hard rel-4.0 - name: Create Pull Request uses: peter-evans/create-pull-request@v3 with: - branch: auto-merge/rel-3-3/${{github.run_number}} - title: Merge branch rel-4.0 with rel-3.3 - body: This PR generated automatically to merge rel-4.0 with rel-3.3. Please review the changed files before merging to prevent any errors that may occur. + branch: auto-rel-4-0-merge-pr-${{github.run_number}} + title: Merge branch rel-4.1 with ${{github.ref}} + body: This PR generated automatically to merge rel-4.1 with rel-4.0. Please review the changed files before merging to prevent any errors that may occur. reviewers: ${{github.actor}} token: ${{ github.token }} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 366972c165..6ba3ad7a6d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-dotnet@master with: - dotnet-version: 3.1.102 + dotnet-version: 5.0.100 - name: Build All run: .\build-all.ps1 diff --git a/.gitignore b/.gitignore index 6e767c8f76..b9576fda4c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.user *.userosscache *.sln.docstates +*.editorconfig # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs @@ -305,3 +306,6 @@ modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/Logs/ /modules/client-simulation/demo/Volo.ClientSimulation.Demo/package-lock.json abp-build-config.json /templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Test/ + +# Identity Server temp signature file +tempkey.jwk \ No newline at end of file diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000000..a0572030a2 --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 9dffe69012..0e252d936d 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,102 @@ [![MyGet (with prereleases)](https://img.shields.io/myget/abp-nightly/vpre/Volo.Abp.svg?style=flat-square)](https://docs.abp.io/en/abp/latest/Nightly-Builds) [![NuGet Download](https://img.shields.io/nuget/dt/Volo.Abp.Core.svg?style=flat-square)](https://www.nuget.org/packages/Volo.Abp.Core) -ABP is an **open source application framework** focused on ASP.NET Core based web application development, but also supports developing other type of applications. +ABP Framework is a complete **infrastructure** based on the **ASP.NET Core** to create **modern web applications** and **APIs** by following the software development **best practices** and the **latest technologies**. -## Links +## Getting Started -* Official Web Site +- [Getting Started Guide](https://docs.abp.io/en/abp/4.0/Getting-Started) is the easiest way to start a new web application with the ABP Framework. +- [Web Application Development Tutorial](https://docs.abp.io/en/abp/4.0/Tutorials/Part-1) is a complete tutorial to develop a full stack web application. + +### Quick Start + +Install the ABP CLI: + +````bash +> dotnet tool install -g Volo.Abp.Cli +```` + +Create a new solution: + +````bash +> abp new BookStore -u mvc -d ef +```` + +> See the [CLI documentation](https://docs.abp.io/en/abp/latest/CLI) for all available options. + +### UI Framework Options + + + +### Database Provider Options + + + +## What ABP Provides? + +ABP provides a **full stack developer experience**. + +### Architecture + + + +ABP offers a complete, **modular** and **layered** software architecture based on **[Domain Driven Design](https://docs.abp.io/en/abp/latest/Domain-Driven-Design)** principles and patterns. It also provides the necessary infrastructure and guiding to [implement this architecture](https://docs.abp.io/en/abp/4.0/Domain-Driven-Design-Implementation-Guide). + +ABP Framework is suitable for **[microservice solutions](https://docs.abp.io/en/abp/latest/Microservice-Architecture)** as well as monolithic applications. + +### Infrastructure + +There are a lot of features provided by the ABP Framework to achieve real world scenarios easier, like [Event Bus](https://docs.abp.io/en/abp/4.0/Event-Bus), [Background Job System](https://docs.abp.io/en/abp/4.0/Background-Jobs), [Audit Logging](https://docs.abp.io/en/abp/4.0/Audit-Logging), [BLOB Storing](https://docs.abp.io/en/abp/4.0/Blob-Storing), [Data Seeding](https://docs.abp.io/en/abp/4.0/Data-Seeding), [Data Filtering](https://docs.abp.io/en/abp/4.0/Data-Filtering), etc. + +### Cross Cutting Concerns + +ABP also simplifies (and even automates wherever possible) cross cutting concerns and common non-functional requirements like [Exception Handling](https://docs.abp.io/en/abp/4.0/Exception-Handling), [Validation](https://docs.abp.io/en/abp/4.0/Validation), [Authorization](https://docs.abp.io/en/abp/4.0/Authorization), [Localization](https://docs.abp.io/en/abp/4.0/Localization), [Caching](https://docs.abp.io/en/abp/4.0/Caching), [Dependency Injection](https://docs.abp.io/en/abp/4.0/Dependency-Injection), [Setting Management](https://docs.abp.io/en/abp/4.0/Settings), etc. + +### Application Modules + +ABP is a modular framework and the Application Modules provide **pre-built application functionalities**; + +- [**Account**](https://docs.abp.io/en/abp/4.0/Modules/Account): Provides UI for the account management and allows user to login/register to the application. +- **[Identity](https://docs.abp.io/en/abp/4.0/Modules/Identity)**: Manages organization units, roles, users and their permissions, based on the Microsoft Identity library. +- [**IdentityServer**](https://docs.abp.io/en/abp/4.0/Modules/IdentityServer): Integrates to IdentityServer4. +- [**Tenant Management**](https://docs.abp.io/en/abp/4.0/Modules/Tenant-Management): Manages tenants for a [multi-tenant](https://docs.abp.io/en/abp/4.0/Multi-Tenancy) (SaaS) application. + +See the [Application Modules](https://docs.abp.io/en/abp/4.0/Modules/Index) document for all pre-built modules. + +### Startup Templates + +The [Startup templates](https://docs.abp.io/en/abp/4.0/Startup-Templates/Index) are pre-built Visual Studio solution templates. You can create your own solution based on these templates to **immediately start your development**. + +## ABP Community + +### ABP Community Web Site + +The [ABP Community](https://community.abp.io/) is a website to publish **articles** and share **knowledge** about the ABP Framework. You can also create content for the community! + +### Blog + +Follow the [ABP Blog](https://blog.abp.io/) to learn the latest happenings in the ABP Framework. + +### Samples + +See the [sample projects](https://docs.abp.io/en/abp/4.0/Samples/Index) built with the ABP Framework. + +### Want to Contribute? + +ABP is a community-driven open source project. See [the contribution guide](https://docs.abp.io/en/abp/4.0/Contribution/Index) if you want to be a part of this project. + +## Official Links + +* Main Web Site * Get Started * Features - * Documentation - * Samples - * Blog +* Documentation +* Samples +* Blog +* Community * Stack overflow * Twitter -## Contribution +## Support the ABP Framework -ABP is an open source platform. Check [the contribution guide](docs/en/Contribution/Index.md) if you want to contribute to the project. +Love ABP Framework? **Please give a star** to this repository :star: \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Account/Localization/Resources/de-DE.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Account/Localization/Resources/de-DE.json new file mode 100644 index 0000000000..b0418f082f --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Account/Localization/Resources/de-DE.json @@ -0,0 +1,14 @@ +{ + "culture": "de-DE", + "texts": { + "Account": "ABP Benutzerkonto - Anmeldung & Registrierung | ABP.IO", + "Welcome": "Willkommen", + "UseOneOfTheFollowingLinksToContinue": "Nutzen Sie einen der nachfolgenden Links um fortzusetzen", + "FrameworkHomePage": "Framework Website", + "FrameworkDocumentation": "Framework Dokumentation", + "OfficialBlog": "Offizieller Blog", + "CommercialHomePage": "Commercial Website", + "CommercialSupportWebSite": "Commercial Support-Website", + "CommunityWebSite": "ABP Community-Website" + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Account/Localization/Resources/es.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Account/Localization/Resources/es.json new file mode 100644 index 0000000000..44ec873da0 --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Account/Localization/Resources/es.json @@ -0,0 +1,14 @@ +{ + "culture": "es", + "texts": { + "Account": "Cuenta de ABP - Iniciar sesión y registrarse | ABP.IO", + "Welcome": "Bienvenido", + "UseOneOfTheFollowingLinksToContinue": "Usa uno de los siguientes links para continuar", + "FrameworkHomePage": "Página de inicio del framework", + "FrameworkDocumentation": "Documentación del framework", + "OfficialBlog": "Blog Oficial", + "CommercialHomePage": "Página de inicio comercial", + "CommercialSupportWebSite": "Sitio web de soporte comercial", + "CommunityWebSite": "Sitio web comunidad ABP" + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/de-DE.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/de-DE.json new file mode 100644 index 0000000000..60725c437b --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/de-DE.json @@ -0,0 +1,199 @@ +{ + "culture": "de-DE", + "texts": { + "Permission:Organizations": "Organisationen", + "Permission:Manage": "Organisationen verwalten", + "Permission:DiscountRequests": "Rabattanfragen", + "Permission:DiscountManage": "Rabattanfragen verwalten", + "Permission:Disable": "Deaktivieren", + "Permission:Enable": "Aktivieren", + "Permission:EnableSendEmail": "E-Mail-Senden aktivieren", + "Permission:SendEmail": "E-Mail senden", + "Permission:NpmPackages": "NPM-Pakete", + "Permission:NugetPackages": "Nuget-Pakete", + "Permission:Maintenance": "Wartung", + "Permission:Maintain": "Warten", + "Permission:ClearCaches": "Caches leeren", + "Permission:Modules": "Module", + "Permission:Packages": "Pakete", + "Permission:Edit": "Bearbeiten", + "Permission:Delete": "Löschen", + "Permission:Create": "Erstellen", + "Permission:Accounting": "Abrechnung", + "Permission:Accounting:Quotation": "Angebot", + "Permission:Accounting:Invoice": "Rechnung", + "Menu:Organizations": "Organisationen", + "Menu:Accounting": "Abrechnung", + "Menu:Packages": "Pakete", + "Menu:DiscountRequests": "Rabattanfragen", + "NpmPackageDeletionWarningMessage": "Dieses NPM-Paket wird entfernt. Bestätigen Sie das?", + "NugetPackageDeletionWarningMessage": "Dieses Nuget-Paket wird entfernt. Bestägiten Sie das?", + "ModuleDeletionWarningMessage": "Dieses Modul wird entfernt. Bestätigen Sie das?", + "Name": "Name", + "DisplayName": "Anzeigename", + "ShortDescription": "Kurzbeschreibung", + "NameFilter": "Name", + "CreationTime": "Erstellungszeitpunkt", + "IsPro": "Ist pro", + "ShowOnModuleList": "In Modulliste anzeigen", + "EfCoreConfigureMethodName": "Methodenname konfigurieren", + "IsProFilter": "Ist pro", + "ApplicationType": "Anwendungstyp", + "Target": "Ziel", + "TargetFilter": "Ziel", + "ModuleClass": "Modulklasse", + "NugetPackageTarget.DomainShared": "Gemeinsame Domain", + "NugetPackageTarget.Domain": "Domain", + "NugetPackageTarget.Application": "Anwendung", + "NugetPackageTarget.ApplicationContracts": "Anwedungsverträge", + "NugetPackageTarget.HttpApi": "HTTP-API", + "NugetPackageTarget.HttpApiClient": "HTTP-API-Client", + "NugetPackageTarget.Web": "Web", + "NugetPackageTarget.EntityFrameworkCore": "DeleteAllEntityFramework Core", + "NugetPackageTarget.MongoDB": "MongoDB", + "Edit": "Bearbeiten", + "Delete": "Löschen", + "Refresh": "Aktualisieren", + "NpmPackages": "NPM-Pakete", + "NugetPackages": "Nuget-Pakete", + "NpmPackageCount": "NPM-Paketanzahl", + "NugetPackageCount": "Nuget-Paketanzahl", + "Module": "Module", + "ModuleInfo": "Modulinfo", + "CreateANpmPackage": "Erstellen Sie ein NPM Paket", + "CreateAModule": "Erstellen Sie in Modul", + "CreateANugetPackage": "Erstellen Sei ein Nuget-Paket", + "AddNew": "Neu hinzufügen", + "PackageAlreadyExist{0}": "\"{0}\" Paket ist bereits hinzugefügt.", + "ModuleAlreadyExist{0}": "\"{0}\" Modul ist bereits hinzugefügt.", + "ClearCache": "Cache leeren", + "SuccessfullyCleared": "Erfolgreich geleert", + "Menu:NpmPackages": "NPM-Pakete", + "Menu:Modules": "Module", + "Menu:Maintenance": "Wartung", + "Menu:NugetPackages": "Nuget-Pakete", + "CreateAnOrganization": "Erstellen Sie eine Organisation", + "Organizations": "Organisationen", + "LongName": "Lange Name", + "LicenseType": "Lizenztyp", + "MissingLicenseTypeField": "Das Feld Lizenztyp ist erforderlich!", + "LicenseStartTime": "Startzeit der Lizenz", + "LicenseEndTime": "Endzeit der Lizenz", + "AllowedDeveloperCount": "Zulässige Entwickleranzahl", + "UserNameOrEmailAddress": "Benutzername oder E-Mail-Adresse", + "AddOwner": "Besitzer hinzufügen", + "UserName": "Benutzername", + "Email": "E-Mail", + "Developers": "Entwickler", + "AddDeveloper": "Entwickler hinzufügen", + "Create": "Erstellen", + "UserNotFound": "Benutzer nicht gefunden", + "{0}WillBeRemovedFromDevelopers": "{0} wird von den Entwicklern entfernt. Bestätigen Sie das?", + "{0}WillBeRemovedFromOwners": "{0} wird von den Besitzern entfernt. Bestätigen Sie das?", + "Computers": "Computer", + "UniqueComputerId": "Eindeutig Computer-ID", + "LastSeenDate": "Zuletzt gesehenes Datum", + "{0}Computer{1}WillBeRemovedFromRecords": "Computer von {0} ({1}) wird aus den Datensätzen entfernt", + "OrganizationDeletionWarningMessage": "Organisation wird gelöscht", + "DeletingLastOwnerWarningMessage": "Eine Organisation muss zumindest einen Besitzer aufweisen! Daher können Sie diesen Besitzer nicht entfernen", + "This{0}AlreadyExistInThisOrganization": "Dies {0} existiert bereits in dieser Organisation", + "AreYouSureYouWantToDeleteAllComputers": "Sind Sie sicher, dass Sie alle Computer löschen möchten?", + "DeleteAll": "Alles Löschen", + "DoYouWantToCreateNewUser": "Möchten Sie einen neuen Benutzer erstellen?", + "MasterModules": "Master-Module", + "OrganizationName": "Organisationsname", + "CreationDate": "Erstellungsdatum", + "LicenseStartDate": "Startdatum der Lizenz", + "LicenseEndDate": "Enddatum der Lizenz", + "OrganizationNamePlaceholder": "Organisationsname...", + "TotalQuestionCountPlaceholder": "Gesamtzahl der Fragen...", + "RemainingQuestionCountPlaceholder": "Anzahl verbleibender Fragen...", + "LicenseTypePlaceholder": "Lizenztyp...", + "CreationDatePlaceholder": "Erstellungsdatum...", + "LicenseStartDatePlaceholder": "Startdatum der Lizenz...", + "LicenseEndDatePlaceholder": "Enddatum der Lizenz...", + "UsernameOrEmail": "Benutzername oder E-Mail-Adresse", + "UsernameOrEmailPlaceholder": "Benutzername oder E-Mail-Adresse...", + "Member": "Mitglied", + "PurchaseOrderNo": "Bestellnummer", + "QuotationDate": "Angebotsdatum", + "CompanyName": "Firmenname", + "CompanyAddress": "Firmenanschrift", + "Price": "Preis", + "DiscountText": "Rabatttext", + "DiscountQuantity": "Rabattmenge", + "DiscountPrice": "Rabattpreis", + "Quotation": "Angebot", + "ExtraText": "Zusätzlicher Text", + "ExtraAmount": "Zusätzliche Menge", + "DownloadQuotation": "Angebot herunterladen", + "Invoice": "Rechnung", + "TaxNumber": "Steuernummer", + "InvoiceNumber": "Rechnungsnummer", + "InvoiceDate": "Rechnungsdatum", + "InvoiceNote": "Rechnungsnotiz", + "Quantity": "Menge", + "AddProduct": "Produkt hinzufügen", + "AddProductWarning": "Sie müssen ein Produkt hinzufügen!", + "TotalPrice": "Gesamtpreis", + "Generate": "Generieren", + "MissingQuantityField": "Das Feld Menge ist erforderlich!", + "MissingPriceField": "Das Feld Preis ist erforderlich!", + "CodeUsageStatus": "Status", + "Country": "Land", + "DeveloperCount": "Entwickleranzahl", + "RequestCode": "Anfrage-Code", + "WebSite": "Webseite", + "GithubUsername": "Github Benutzername", + "PhoneNumber": "Telefonnummer", + "ProjectDescription": "Projektbeschreibung", + "Referrer": "Referrer", + "DiscountRequests": "Rabattanfrage", + "Copylink": "Link kopieren", + "Disable": "Deaktivieren", + "Enable": "Aktivieren", + "EnableSendEmail": "E-Mail-Senden aktivieren", + "SendEmail": "E-Mail senden", + "SuccessfullyDisabled": "Erfolgreich deaktiviert", + "SuccessfullyEnabled": "Erfolgreich aktiviert", + "EmailSent": "E-Mail gesendet", + "SuccessfullySent": "Erfolgreich gesendet", + "SuccessfullyDeleted": "Erfolgreich gelöscht", + "DiscountRequestDeletionWarningMessage": "Rabattanfrage wird gelöscht", + "BusinessType": "Unternehmensart", + "TotalQuestionCount": "Gesamtzahl der Fragen", + "RemainingQuestionCount": "Anzahl verbleibender Fragen", + "TotalQuestionMustBeGreaterWarningMessage": "TotalQuestionCount muss größer sein als RemainingQuestionCount !", + "QuestionCountsMustBeGreaterThanZero": "TotalQuestionCount und RemainingQuestionCount müssen Null oder größer als Null sein !", + "UnlimitedQuestionCount": "Unbegrenzte Anzahl von Fragen", + "Notes": "Anmerkungen", + "Menu:Community": "Community", + "Menu:Articles": "Beiträge", + "Wait": "Warten", + "Approve": "Genehmigen", + "Reject": "Ablehnen", + "Details": "Details", + "Url": "URL", + "Title": "Titel", + "ContentSource": "Inhaltsquelle", + "Status": "Status", + "ReadArticle": "Beitrag lesen", + "ArticleHasBeenWaiting": "Beitrag hat gewartet", + "ArticleHasBeenApproved": "Beitrag wurde genehmigt", + "ArticleHasBeenRejected": "Beitrag wurde abgelehnt", + "Permission:Community": "Community", + "Permission:CommunityArticle": "Beitrag", + "Link": "Link", + "Enum:ContentSource:0": "Github", + "Enum:ContentSource:1": "Extern", + "Enum:Status:0": "Wartend", + "Enum:Status:1": "Abgelehnt", + "Enum:Status:2": "Genehmigt", + "Summary": "Zusammenfassung", + "AuthorName": "Autorenname", + "CoverImage": "Titelbild", + "RemoveCacheConfirmationMessage": "Sind Sie sicher, dass Sie den Cache für den Artikel \"{0}\" entfernen wollen?", + "SuccessfullyRemoved": "Erfolgreich geleert", + "RemoveCache": "Cache entfernen" + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/es.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/es.json new file mode 100644 index 0000000000..1cf2e4f365 --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/es.json @@ -0,0 +1,199 @@ +{ + "culture": "es", + "texts": { + "Permission:Organizations": "Organizaciones", + "Permission:Manage": "Gestionar organizaciones", + "Permission:DiscountRequests": "Solicitudes de descuento", + "Permission:DiscountManage": "Gestionar solicitudes de descuento", + "Permission:Disable": "Desactivar", + "Permission:Enable": "Activar", + "Permission:EnableSendEmail": "Activar enviar email", + "Permission:SendEmail": "Enviar email", + "Permission:NpmPackages": "Paquetes NPM", + "Permission:NugetPackages": "Paquetes Nuget", + "Permission:Maintenance": "Mantenimiento", + "Permission:Maintain": "Mantener", + "Permission:ClearCaches": "Borrar cachés", + "Permission:Modules": "Módulos", + "Permission:Packages": "Paquetes", + "Permission:Edit": "Editar", + "Permission:Delete": "Borrar", + "Permission:Create": "Crear", + "Permission:Accounting": "Contabilidad", + "Permission:Accounting:Quotation": "Cotización", + "Permission:Accounting:Invoice": "Factura", + "Menu:Organizations": "Organizaciones", + "Menu:Accounting": "Contabilidad", + "Menu:Packages": "Paquetes", + "Menu:DiscountRequests": "Solicitudes de descuento", + "NpmPackageDeletionWarningMessage": "Este NPM paquete será borrado. ¿Quieres confirmar?", + "NugetPackageDeletionWarningMessage": "Este NPM paquete será borrado. ¿Quieres confirmar?", + "ModuleDeletionWarningMessage": "Este NPM paquete será borrado. ¿Quieres confirmar?", + "Name": "Nombre", + "DisplayName": "Nombre para mostrar", + "ShortDescription": "Descripción corta", + "NameFilter": "Nombre", + "CreationTime": "Fecha de creación", + "IsPro": "Es pro", + "ShowOnModuleList": "Mostrar en la lista de módulos", + "EfCoreConfigureMethodName": "configurar nombre de método", + "IsProFilter": "Es pro", + "ApplicationType": "tipo de aplicación", + "Target": "Destino", + "TargetFilter": "Destino", + "ModuleClass": "Módulo de clase", + "NugetPackageTarget.DomainShared": "Dominio compartido", + "NugetPackageTarget.Domain": "Dominio", + "NugetPackageTarget.Application": "Aplicación", + "NugetPackageTarget.ApplicationContracts": "Contratos de aplicación", + "NugetPackageTarget.HttpApi": "Http Api", + "NugetPackageTarget.HttpApiClient": "Cliente Http Api", + "NugetPackageTarget.Web": "Web", + "NugetPackageTarget.EntityFrameworkCore": "Delete todo EntityFramework Core", + "NugetPackageTarget.MongoDB": "MongoDB", + "Edit": "Editar", + "Delete": "Borrar", + "Refresh": "Refrescar", + "NpmPackages": "Paquetes NPM", + "NugetPackages": "Paquetes Nuget", + "NpmPackageCount": "Número de paquetes NPM", + "NugetPackageCount": "Número de paquetes Nuget", + "Module": "Módulos", + "ModuleInfo": "Info de módulo", + "CreateANpmPackage": "Crear un paquete NPM", + "CreateAModule": "Crear un módulo", + "CreateANugetPackage": "Crear un paquete de Nuget", + "AddNew": "Añadir nuevo", + "PackageAlreadyExist{0}": "\"{0}\" paquete ya se encuentra añadido", + "ModuleAlreadyExist{0}": "\"{0}\" módulo ya se encuentra añadido.", + "ClearCache": "Borrar caché", + "SuccessfullyCleared": "Borrado satisfactoriamente", + "Menu:NpmPackages": "Paquetes de NPM", + "Menu:Modules": "Módulos", + "Menu:Maintenance": "Mantenimiento", + "Menu:NugetPackages": "Paquetes Nuget", + "CreateAnOrganization": "Crear una organización", + "Organizations": "Organizaciones", + "LongName": "Nombre largo", + "LicenseType": "Tipo de licencia", + "MissingLicenseTypeField": "El campo tipo de licencia es requerido!", + "LicenseStartTime": "Fecha de inicio de licencia", + "LicenseEndTime": "Fecha de caducidad de licencia", + "AllowedDeveloperCount": "Número de desarrolladores permitidos", + "UserNameOrEmailAddress": "Nombre de usuario o", + "AddOwner": "Añadir propietario", + "UserName": "Nombre de usuario", + "Email": "Email", + "Developers": "Desarrolladores", + "AddDeveloper": "Añadir desarrollador", + "Create": "Crear", + "UserNotFound": "Usuario no encontrado", + "{0}WillBeRemovedFromDevelopers": "{0} será eliminado de desarrolladores, ¿deseas continuar?", + "{0}WillBeRemovedFromOwners": "{0} será eliminado de propietarios, ¿deseas continuar?", + "Computers": "Ordenadores", + "UniqueComputerId": "Id única de ordenador", + "LastSeenDate": "Fecha de visto por última vez", + "{0}Computer{1}WillBeRemovedFromRecords": "El ordenador {0} ({1}) será eliminado de los registros", + "OrganizationDeletionWarningMessage": "La organización será eliminada", + "DeletingLastOwnerWarningMessage": "Una organización debe tener al menos un propietario!. Por lo tanto, tu no puedes eliminar este propietario", + "This{0}AlreadyExistInThisOrganization": "Este/a {0} ya existe en esta organización", + "AreYouSureYouWantToDeleteAllComputers": "Estás seguro tu quieres eliminar todos los ordenadores", + "DeleteAll": "Eliminar todo", + "DoYouWantToCreateNewUser": "¿Quieres crear un nuevo usuario?", + "MasterModules": "Módulos maestros", + "OrganizationName": "Nombre de organización", + "CreationDate": "Fecha de creación", + "LicenseStartDate": "Fecha de inicio de licencia", + "LicenseEndDate": "Fecha de caducidad de licencia", + "OrganizationNamePlaceholder": "Nombre de organización...", + "TotalQuestionCountPlaceholder": "Número total de preguntas...", + "RemainingQuestionCountPlaceholder": "Número de preguntas pendientes", + "LicenseTypePlaceholder": "Tipo de licencia...", + "CreationDatePlaceholder": "Fecha de creación...", + "LicenseStartDatePlaceholder": "Fecha de inicio de licencia...", + "LicenseEndDatePlaceholder": "Fecha de caducidad de licencia...", + "UsernameOrEmail": "Usuario o email", + "UsernameOrEmailPlaceholder": "Usuario o email...", + "Member": "Miembro", + "PurchaseOrderNo": "Número de orden de compra", + "QuotationDate": "", + "CompanyName": "", + "CompanyAddress": "", + "Price": "", + "DiscountText": "", + "DiscountQuantity": "", + "DiscountPrice": "", + "Quotation": "", + "ExtraText": "", + "ExtraAmount": "", + "DownloadQuotation": "", + "Invoice": "", + "TaxNumber": "", + "InvoiceNumber": "", + "InvoiceDate": "", + "InvoiceNote": "", + "Quantity": "", + "AddProduct": "", + "AddProductWarning": "", + "TotalPrice": "", + "Generate": "", + "MissingQuantityField": "", + "MissingPriceField": "", + "CodeUsageStatus": "", + "Country": "", + "DeveloperCount": "", + "RequestCode": "", + "WebSite": "", + "GithubUsername": "", + "PhoneNumber": "", + "ProjectDescription": "", + "Referrer": "", + "DiscountRequests": "", + "Copylink": "", + "Disable": "", + "Enable": "", + "EnableSendEmail": "", + "SendEmail": "", + "SuccessfullyDisabled": "", + "SuccessfullyEnabled": "", + "EmailSent": "", + "SuccessfullySent": "", + "SuccessfullyDeleted": "", + "DiscountRequestDeletionWarningMessage": "", + "BusinessType": "", + "TotalQuestionCount": "", + "RemainingQuestionCount": "", + "TotalQuestionMustBeGreaterWarningMessage": "", + "QuestionCountsMustBeGreaterThanZero": "", + "UnlimitedQuestionCount": "", + "Notes": "", + "Menu:Community": "", + "Menu:Articles": "", + "Wait": "", + "Approve": "", + "Reject": "", + "Details": "", + "Url": "", + "Title": "", + "ContentSource": "", + "Status": "", + "ReadArticle": "", + "ArticleHasBeenWaiting": "", + "ArticleHasBeenApproved": "", + "ArticleHasBeenRejected": "", + "Permission:Community": "", + "Permission:CommunityArticle": "", + "Link": "", + "Enum:ContentSource:0": "", + "Enum:ContentSource:1": "", + "Enum:Status:0": "", + "Enum:Status:1": "", + "Enum:Status:2": "", + "Summary": "", + "AuthorName": "", + "CoverImage": "", + "RemoveCacheConfirmationMessage": "", + "SuccessfullyRemoved": "", + "RemoveCache": "" + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/de-DE.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/de-DE.json new file mode 100644 index 0000000000..77e1b2090a --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/de-DE.json @@ -0,0 +1,33 @@ +{ + "culture": "de-DE", + "texts": { + "Volo.AbpIo.Domain:010004": "Maximale Mitgliederanzahl erreicht!", + "Volo.AbpIo.Domain:010005": "Miximale Besizeranzahl erreicht!", + "Volo.AbpIo.Domain:010006": "Dieser Benutzer ist bereits ein Besitzer in dieser Organisation!", + "Volo.AbpIo.Domain:010007": "Dieser Benutzer ist bereits ein Entwickler in dieser Organisation!", + "Volo.AbpIo.Domain:010008": "Die zulässige Entwickleranzahl darf nicht geringer sein als die aktuelle Entwickleranzahl!", + "Volo.AbpIo.Domain:010009": "Die zulässige Entwickleranzahl darf nicht kleiner als 0 sein!", + "Volo.AbpIo.Domain:010010": "Die maximale Anzahl der Mac-Adressen ist überschritten!", + "Volo.AbpIo.Domain:010011": "Die persönliche Lizenz kann nicht mehr als 1 Entwickler haben!", + "Volo.AbpIo.Domain:010012": "Die Lizenz kann nicht einen Monat nach Ablauf der Lizenz verlängert werden!", + "Volo.AbpIo.Domain:020001": "Dieses NPM-Paket konnte nicht gelöscht werden, da \"{NugetPackages}\" Nuget-Pakete von diesem Paket abhängig sind.", + "Volo.AbpIo.Domain:020002": "Dieses NPM-Paket konnte nicht gelöscht werden, da \"{Module}\" Module dieses Paket verwenden.", + "Volo.AbpIo.Domain:020003": "Dieses NPM-Paket konnte nicht gelöscht werden, da \"{Module}\" Module dieses Paket verwenden und \"{NugetPackages}\" Nuget-Pakete von diesem Paket abhängig sind.", + "Volo.AbpIo.Domain:020004": "Dieses Nuget-Paket konnte nicht gelöscht werden, da \"{Module}\" Module dieses Paket verwenden.", + "WantToLearn?": "Wollen Sie sich einlernen?", + "ReadyToGetStarted?": "Bereit anzufangen?", + "JoinOurCommunity": "Tritt unserer Community bei", + "GetStartedUpper": "LOSLEGEN", + "ForkMeOnGitHub": "Fork me on GitHub", + "Features": "Features", + "GetStarted": "Loslegen", + "Documents": "Unterlagen", + "Community": "Community", + "ContributionGuide": "Leitfaden für Mitwirkende", + "Blog": "Blog", + "Commercial": "Commercial", + "MyAccount": "Mein Benutzerkonto", + "SeeDocuments": "Siehe Unterlagen", + "Samples": "Beispiele" + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/es.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/es.json new file mode 100644 index 0000000000..2b210888c5 --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Base/Localization/Resources/es.json @@ -0,0 +1,33 @@ +{ + "culture": "es", + "texts": { + "Volo.AbpIo.Domain:010004": "", + "Volo.AbpIo.Domain:010005": "", + "Volo.AbpIo.Domain:010006": "", + "Volo.AbpIo.Domain:010007": "", + "Volo.AbpIo.Domain:010008": "", + "Volo.AbpIo.Domain:010009": "", + "Volo.AbpIo.Domain:010010": "", + "Volo.AbpIo.Domain:010011": "", + "Volo.AbpIo.Domain:010012": "", + "Volo.AbpIo.Domain:020001": "", + "Volo.AbpIo.Domain:020002": "", + "Volo.AbpIo.Domain:020003": "", + "Volo.AbpIo.Domain:020004": "", + "WantToLearn?": "", + "ReadyToGetStarted?": "", + "JoinOurCommunity": "", + "GetStartedUpper": "", + "ForkMeOnGitHub": "", + "Features": "", + "GetStarted": "", + "Documents": "", + "Community": "", + "ContributionGuide": "", + "Blog": "", + "Commercial": "", + "MyAccount": "", + "SeeDocuments": "", + "Samples": "" + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/de-DE.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/de-DE.json new file mode 100644 index 0000000000..ddc493e63b --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/de-DE.json @@ -0,0 +1,35 @@ +{ + "culture": "de-DE", + "texts": { + "OrganizationManagement": "Organisationsverwaltung", + "OrganizationList": "Organisationsauflistung", + "Volo.AbpIo.Commercial:010003": "Sie sind der Besitzer dieser Organisation!", + "OrganizationNotFoundMessage": "Keine Organisation gefunden!", + "DeveloperCount": "Zugeordnete / Gesamte Entwickler", + "QuestionCount": "Verbleibende / Gesamte Fragen", + "Unlimited": "Unbegrenzt", + "Owners": "Besitzer", + "AddMember": "Mitglied hinzufügen", + "AddOwner": "Besizer hinzufügen", + "AddDeveloper": "Entwickler hinzufügen", + "UserName": "Benutzername", + "Name": "Name", + "EmailAddress": "E-Mail-Adress", + "Developers": "Entwickler", + "LicenseType": "Lizenztyp", + "Manage": "Verwalten", + "StartDate": "Startdatum", + "EndDate": "Enddatum", + "Modules": "Module", + "LicenseExtendMessage": "Ihr Lizenzenddatum wird auf {0} verlängert", + "LicenseUpgradeMessage": "Ihre Lizenz wird auf {0} aktualisiert", + "LicenseAddDeveloperMessage": "{0} Entwickler zu Ihrer Lizenz hinzugefügt", + "Volo.AbpIo.Commercial:010004": "Kann den angegebenen Benutzer nicht finden! Der Benutzer muss sich bereits registriert haben.", + "MyOrganizations": "Meine Organisationen", + "ApiKey": "API-Schlüssel", + "UserNameNotFound": "Es gibt keinen Benutzer mit dem Benutzernamen {0}", + "SuccessfullyAddedToNewsletter": "Vielen Dank, dass Sie unseren Newsletter abonniert haben!", + "MyProfile": "Mein Profil", + "EmailNotValid": "Bitte geben Sie eine gültige E-Mail-Adresse ein." + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json index 2a57c6b25d..e029499b06 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json @@ -30,6 +30,8 @@ "UserNameNotFound": "There is no user with username {0}", "SuccessfullyAddedToNewsletter": "Thanks you for subscribing to our newsletter!", "MyProfile": "My profile", - "EmailNotValid": "Please enter a valid email address." + "EmailNotValid": "Please enter a valid email address.", + "JoinOurMarketingNewsletter": "Join our marketing newsletter", + "WouldLikeToReceiveMarketingMaterials": "I would like to receive marketing materials like product deals & special offers." } } \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/es.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/es.json new file mode 100644 index 0000000000..7aa24608d4 --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/es.json @@ -0,0 +1,35 @@ +{ + "culture": "es", + "texts": { + "OrganizationManagement": "", + "OrganizationList": "", + "Volo.AbpIo.Commercial:010003": "", + "OrganizationNotFoundMessage": "", + "DeveloperCount": "", + "QuestionCount": "", + "Unlimited": "", + "Owners": "", + "AddMember": "", + "AddOwner": "", + "AddDeveloper": "", + "UserName": "", + "Name": "", + "EmailAddress": "", + "Developers": "", + "LicenseType": "Tipo de licencia", + "Manage": "", + "StartDate": "", + "EndDate": "", + "Modules": "Módulos", + "LicenseExtendMessage": "", + "LicenseUpgradeMessage": "", + "LicenseAddDeveloperMessage": "", + "Volo.AbpIo.Commercial:010004": "", + "MyOrganizations": "", + "ApiKey": "", + "UserNameNotFound": "", + "SuccessfullyAddedToNewsletter": "", + "MyProfile": "", + "EmailNotValid": "" + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/de-DE.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/de-DE.json new file mode 100644 index 0000000000..cc8d76012c --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/de-DE.json @@ -0,0 +1,90 @@ +{ + "culture": "de-DE", + "texts": { + "Permission:CommunityArticle": "Community-Beitrag", + "Permission:Edit": "Bearbeiten", + "Waiting": "Wartend", + "Approved": "Genehmigt", + "Rejected": "Abgelehnt", + "Wait": "Warten", + "Approve": "Genehmigen", + "Reject": "Ablehnen", + "ReadArticle": "Beitrag lesen", + "Status": "Status", + "ContentSource": "Inhaltsquelle", + "Details": "Details", + "Url": "URL", + "Title": "Titel", + "CreationTime": "Erstellungszeitpunkt", + "Save": "Speichern", + "SameUrlAlreadyExist": "Dieselbe URL existiert bereits, wenn Sie diesen Beitrag hinzufügen möchten, sollten Sie die URL ändern!", + "UrlIsNotValid": "Der URL ist nicht korrekt.", + "UrlNotFound": "URL nicht gefunden.", + "UrlContentNotFound": "URL-Inhalt nicht gefunden", + "Summary": "Zusammenfassung", + "MostRead": "Meist gelesen", + "Latest": "Neueste", + "ContributeAbpCommunity": "Tragen Sie zur ABP Community bei", + "SubmitYourArticle": "Reichen Sie Ihren Beitrag ein", + "ContributionGuide": "Leitfaden für Mitwirkende", + "BugReport": "Fehler melden", + "SeeAllArticles": "Alle Beiträge anzeigen", + "WelcomeToABPCommunity!": "Willkommen in der ABP Community!", + "MyProfile": "Mein Profil", + "MyOrganizations": "Meine Organisationen", + "EmailNotValid": "Bitte geben Sie eine gültige E-Mail-Adresse ein.", + "FeatureRequest": "Featureanfrage", + "CreateArticleTitleInfo": "Titel des Beitrags, der in der Beitragsliste angezeigt werden soll.", + "CreateArticleUrlInfo": "Original GitHub-/externe URL des Beitrags.", + "CreateArticleSummaryInfo": "Eine kurze Zusammenfassung des Beitrags, der in der Beitragsliste angezeigt werden soll.", + "CreateArticleCoverInfo": "Fügen Sie zum Erstellen eines effektiven Beitrags ein Titelbild hinzu. Laden Sie Bilder mit einem Seitenverhältnis von 16: 9 hoch, um die beste Ansicht zu erhalten.", + "ThisExtensionIsNotAllowed": "Diese Erweiterung ist nicht zulässig.", + "TheFileIsTooLarge": "Die Datei ist zu groß.", + "GoToTheArticle": "Gehe zum Beitrag", + "Contribute": "Beitragen", + "OverallProgress": "Gesamtfortschritt", + "Done": "Ferig", + "Open": "Offen", + "Closed": "Geschlossen", + "LatestQuestionOnThe": "Letzte Frage zum", + "Stackoverflow": "Stackoverflow", + "Votes": "Stimmen", + "Answer": "Antworten", + "Views": "Ansichten", + "Answered": "Beantwortet", + "WaitingForYourAnswer": "Warten auf Ihre Antwort", + "Asked": "gefragt", + "AllQuestions": "Alle Fragen", + "NextVersion": "Nächste Version", + "MilestoneErrorMessage": "Die aktuellen Meilensteindetails konnten von Github nicht abgerufen werden.", + "QuestionItemErrorMessage": "Die neuesten Fragendetails konnten von Stackoverflow nicht abgerufen werden.", + "Oops": "Hoppla!", + "CreateArticleSuccessMessage": "Der Beitrag wurde erfolgreich eingereicht. Er wird nach einer Überprüfung durch den Site-Administrator veröffentlicht.", + "ChooseCoverImage": "Wählen Sie ein Titelbild ...", + "CoverImage": "Titelbild", + "ShareYourExperiencesWithTheABPFramework": "Teilen Sie Ihre Erfahrungen mit dem ABP Framework!", + "Optional": "Optional", + "UpdateUserWebSiteInfo": "Beispiel: https://johndoe.com", + "UpdateUserTwitterInfo": "Beispiel: johndoe", + "UpdateUserGithubInfo": "Beispiel: johndoe", + "UpdateUserLinkedinInfo": "Beispiel: https://www.linkedin.com/...", + "UpdateUserCompanyInfo": "Beispiel: Volosoft", + "UpdateUserJobTitleInfo": "Beispiel: Software Developer", + "UserName": "Benutzername", + "Company": "Firma", + "PersonalWebsite": "Persönliche Website", + "RegistrationDate": "Registrierungsdatum", + "Social": "Social", + "Biography": "Biographie", + "HasNoPublishedArticlesYet": "hat noch keine Beiträge veröffentlicht", + "Author": "Autor", + "LatestGithubAnnouncements": "Neueste Github-Ankündigungen", + "SeeAllAnnouncements": "Alle Ankündigungen anzeigen", + "LatestBlogPost": "Letzter Blog-Beitrag", + "Edit": "Bearbeiten", + "ProfileImageChange": "Ändern Sie das Profilbild", + "BlogItemErrorMessage": "Die neuesten Blogpost-Details konnten von ABP nicht abgerufen werden.", + "PlannedReleaseDate": "Geplantes Erscheinungsdatum", + "CommunityArticleRequestErrorMessage": "Die Anfrage nach den neuesten Beiträgen von Github konnte nicht abgerufen werden." + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json index 2544e50726..c570e6fb1e 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json @@ -84,6 +84,21 @@ "Edit": "Edit", "ProfileImageChange": "Change the profile image", "BlogItemErrorMessage": "Could not get the latest blog post details from ABP.", - "PlannedReleaseDate": "Planned release date" + "PlannedReleaseDate": "Planned release date", + "CommunityArticleRequestErrorMessage": "Could not get the latest article request from Github.", + "ArticleRequestFromGithubIssue": "There are not any article requests now.", + "LatestArticles": "Latest Articles", + "ArticleRequests": "Article Requests", + "AllArticleRequests": "See All Article Requests", + "SubscribeToTheNewsletter": "Subscribe to the Newsletter", + "NewsletterEmailDefinition": "Get information about happenings in ABP like new releases, free sources, articles, and more.", + "NoThanks": "No, thanks", + "MaybeLater": "Maybe later", + "JoinOurArticleNewsletter": "Join our article newsletter", + "Community": "Community", + "Marketing": "Marketing", + "CommunityPrivacyPolicyConfirmation": "I agree to the Terms & Conditions and Privacy Policy.", + "ArticleRequestMessageTitle": "Open an issue on the GitHub to request an article/tutorial you want to see on this web site.", + "ArticleRequestMessageBody": "Here, the list of the requested articles by the community. Do you want to write a requested article? Please click to the request and join to the discussion." } } diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/es.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/es.json new file mode 100644 index 0000000000..d495720a93 --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/es.json @@ -0,0 +1,90 @@ +{ + "culture": "es", + "texts": { + "Permission:CommunityArticle": "", + "Permission:Edit": "", + "Waiting": "", + "Approved": "", + "Rejected": "", + "Wait": "", + "Approve": "", + "Reject": "", + "ReadArticle": "", + "Status": "", + "ContentSource": "", + "Details": "", + "Url": "", + "Title": "", + "CreationTime": "", + "Save": "Guardar", + "SameUrlAlreadyExist": "", + "UrlIsNotValid": "", + "UrlNotFound": "", + "UrlContentNotFound": "", + "Summary": "", + "MostRead": "", + "Latest": "", + "ContributeAbpCommunity": "", + "SubmitYourArticle": "", + "ContributionGuide": "", + "BugReport": "", + "SeeAllArticles": "", + "WelcomeToABPCommunity!": "", + "MyProfile": "", + "MyOrganizations": "", + "EmailNotValid": "", + "FeatureRequest": "", + "CreateArticleTitleInfo": "", + "CreateArticleUrlInfo": "", + "CreateArticleSummaryInfo": "", + "CreateArticleCoverInfo": "", + "ThisExtensionIsNotAllowed": "", + "TheFileIsTooLarge": "", + "GoToTheArticle": "", + "Contribute": "", + "OverallProgress": "", + "Done": "", + "Open": "", + "Closed": "", + "LatestQuestionOnThe": "", + "Stackoverflow": "", + "Votes": "", + "Answer": "", + "Views": "", + "Answered": "", + "WaitingForYourAnswer": "", + "Asked": "", + "AllQuestions": "", + "NextVersion": "", + "MilestoneErrorMessage": "", + "QuestionItemErrorMessage": "", + "Oops": "", + "CreateArticleSuccessMessage": "", + "ChooseCoverImage": "", + "CoverImage": "", + "ShareYourExperiencesWithTheABPFramework": "", + "Optional": "", + "UpdateUserWebSiteInfo": "", + "UpdateUserTwitterInfo": "", + "UpdateUserGithubInfo": "", + "UpdateUserLinkedinInfo": "", + "UpdateUserCompanyInfo": "", + "UpdateUserJobTitleInfo": "", + "UserName": "", + "Company": "", + "PersonalWebsite": "", + "RegistrationDate": "", + "Social": "", + "Biography": "", + "HasNoPublishedArticlesYet": "", + "Author": "", + "LatestGithubAnnouncements": "", + "SeeAllAnnouncements": "", + "LatestBlogPost": "", + "Edit": "", + "ProfileImageChange": "", + "BlogItemErrorMessage": "", + "PlannedReleaseDate": "", + "CommunityArticleRequestErrorMessage": "" + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/de-DE.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/de-DE.json new file mode 100644 index 0000000000..6f9f0726cf --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/de-DE.json @@ -0,0 +1,189 @@ +{ + "culture": "de-DE", + "texts": { + "GetStarted": "Erste Schritte - Startvorlagen", + "Create": "Erstellen", + "NewProject": "Neues Projekt", + "DirectDownload": "Direkter Download", + "ProjectName": "Proejktname", + "ProjectType": "Projekttyp", + "DatabaseProvider": "Datenbankanbieter", + "NTier": "N-Tier", + "IncludeUserInterface": "Benutzeroberfläche einschließen", + "CreateNow": "Jetzt erstellen", + "TheStartupProject": "Das Startprojekt", + "Tutorial": "Lernprogramm", + "UsingCLI": "mit CLI", + "SeeDetails": "Details ansehen", + "AbpShortDescription": "ABP Framework ist eine vollständige Infrastruktur zum Erstellen moderner Webanwendungen unter Befolgung von Best Practices und Konventionen für Softwareentwicklung.", + "SourceCodeUpper": "QUELLCODE", + "LatestReleaseLogs": "Akteulle Release", + "Infrastructure": "Infrastrutkur", + "Architecture": "Architektur", + "Modular": "Modular", + "DontRepeatYourself": "Don't Repeat Yourself", + "DeveloperFocused": "Entwickler-Zentriert", + "FullStackApplicationInfrastructure": "Full-Stack-Anwendungsinfrastruktur.", + "DomainDrivenDesign": "Domain Driven Design", + "DomainDrivenDesignExplanation": "Entworfen und entwickelt basierend auf DDD-Mustern und -Prinzipien. Bietet ein Schichtenmodell für Ihre Anwendung.", + "Authorization": "Authorization", + "AuthorizationExplanation": "Erweiterte Autorisierung mit Benutzer-, Rollen- und fein abgestimmtem Berechtigungssystem. Aufbauend auf der Microsoft Identity-Bibliothek.", + "MultiTenancy": "Multi-Tenancy", + "MultiTenancyExplanationShort": "SaaS-Anwendungen leicht gemacht! Integrierte Mandantenfähigkeit von der Datenbank bis zur Benutzeroberfläche.", + "CrossCuttingConcerns": "Cross Cutting Concerns", + "CrossCuttingConcernsExplanationShort": "Komplette Infrastruktur für Autorisierung, Validierung, Ausnahmebehandlung, Caching, Überwachungsprotokollierung, Transaktionsverwaltung und mehr.", + "BuiltInBundlingMinification": "Built-In Bundling & Minification", + "BuiltInBundlingMinificationExplanation": "Für die Bundling und Minification müssen keine externen Tools verwendet werden. ABP bietet eine einfachere, dynamische, leistungsstarke, modulare und integrierte Methode!", + "VirtualFileSystem": "Virtual File System", + "VirtualFileSystemExplanation": "Betten Sie Ansichten, Skripte, Stile, Bilder ... in Pakete/Bibliotheken ein und verwenden Sie sie in verschiedenen Anwendungen wieder.", + "Theming": "Theming", + "ThemingExplanationShort": "Verwenden und passen Sie das Bootstrap-basierte Standard-UI-Design an oder erstellen Sie Ihr eigenes.", + "BootstrapTagHelpersDynamicForms": "Bootstrap Tag Helpers & Dynamic Forms", + "BootstrapTagHelpersDynamicFormsExplanation": "Anstatt die sich wiederholenden Details von Bootstrap-Komponenten manuell zu schreiben, verwenden Sie die Tag-Helper von ABP, um diese zu vereinfachen und dabei die Vorteile von Intellisense zu nutzen. Erstellen Sie mit dem dynamischen Formular-Tag-Helfer schnell UI-Formulare basierend auf einem C#-Modell.", + "HTTPAPIsDynamicProxies": "HTTP APIs & Dynamic Proxies", + "HTTPAPIsDynamicProxiesExplanation": "Stellen Sie Anwendungsdienste automatisch als HTTP-APIs im REST-Stil bereit und verwenden Sie diese mit dynamischen JavaScript- und C#-Proxys.", + "CompleteArchitectureInfo": "Moderne Architektur zur Erstellung wartbarer Softwarelösungen.", + "DomainDrivenDesignBasedLayeringModelExplanation": "Hilft Ihnen bei der Implementierung einer DDD-basierten Schichtarchitektur und beim Aufbau einer wartbaren Codebasis.", + "DomainDrivenDesignBasedLayeringModelExplanationCont": "Bietet Startvorlagen, Abstraktionen, Basisklassen, Dienste, Dokumentation und Anleitungen, mit denen Sie Ihre Anwendung basierend auf DDD-Mustern und -Prinzipien entwickeln können.", + "MicroserviceCompatibleModelExplanation": "Das Kernframework und die vorgefertigten Module sind unter Berücksichtigung der Microservice-Architektur konzipiert.", + "MicroserviceCompatibleModelExplanationCont": "Bietet Infrastruktur, Integrationen, Beispiele und Dokumentation zur einfacheren Implementierung von Microservice-Lösungen, ohne zusätzliche Komplexität zu verursachen, wenn Sie eine monolithische Anwendung wünschen.", + "ModularInfo": "ABP bietet ein Modulsystem, mit dem Sie wiederverwendbare Anwendungsmodule entwickeln, Ereignisse im Anwendungslebenszyklus verknüpfen und Abhängigkeiten zwischen Kernteilen Ihres Systems ausdrücken können.", + "PreBuiltModulesThemes": "Vorgefertigte Module & Themes", + "PreBuiltModulesThemesExplanation": "Open Source- und kommerzielle Module und Themes stehen bereit, um in Ihrer Geschäftsanwendung verwendet zu werden.", + "NuGetNPMPackages": "NuGet- & NPM-Pakete", + "NuGetNPMPackagesExplanation": "Bereitgestellt als NuGet- & NPM-Pakete. Einfach zu installieren und zu aktualisieren.", + "ExtensibleReplaceable": "Erweiterbar/Austauschbar", + "ExtensibleReplaceableExplanation": "Alle Dienste und Module sind auf Erweiterbarkeit ausgelegt. Sie können Dienste, Seiten, Stile und Komponenten ersetzen.", + "CrossCuttingConcernsExplanation2": "Halten Sie Ihre Codebasis kleiner, damit Sie sich auf ihre geschäftsspezifischen Code konzentrieren können.", + "CrossCuttingConcernsExplanation3": "Verbringen Sie keine Zeit damit, grundlegende Anwendungsanforderungen für jedes neue Projekte zu implementieren.", + "AuthenticationAuthorization": "Authentifizierung & Autorisierung", + "ExceptionHandling": "Fehlerbehandlung", + "Validation": "Validierung", + "DatabaseConnection": "Datenbankverbindung", + "TransactionManagement": "Transaktionsmanagement", + "AuditLogging": "Audit Logging", + "Caching": "Caching", + "Multitenancy": "Multimandantenfähigkeit", + "DataFiltering": "Datenfilterung", + "ConventionOverConfiguration": "Convention Over Configuration", + "ConventionOverConfigurationExplanation": "ABP implementiert standardmäßig allgemeine Anwendungskonventionen mit einer minimalen oder Null-Konfiguration.", + "ConventionOverConfigurationExplanationList1": "Automatische Registrierung bekannter Services für Dependency Injection.", + "ConventionOverConfigurationExplanationList2": "Stellt Anwendungsdienste mittels Namenskonventionen als HTTP-APIs bereit.", + "ConventionOverConfigurationExplanationList3": "Erstellt dynamische HTTP-Client-Proxys für C# und JavaScript.", + "ConventionOverConfigurationExplanationList4": "Bietet Standard-Repositorys für Ihre Entities.", + "ConventionOverConfigurationExplanationList5": "Verwaltet die Unit-of-Work gemäß Webanforderung oder Anwendungsdienstmethode.", + "ConventionOverConfigurationExplanationList6": "Triggert Erstellungs-, Aktualisierungs- und Lösch-Events für Ihre Entities.", + "BaseClasses": "Basisklassen", + "BaseClassesExplanation": "Vorgefertigte Basisklassen für gängige Anwendungsmuster.", + "DeveloperFocusedExplanation": "ABP ist für Entwickler", + "DeveloperFocusedExplanationCont": "Es zielt darauf ab, Ihre tägliche Softwareentwicklung zu vereinfachen, ohne Sie daran zu hindern, Low-Level-Code zu schreiben.", + "SeeAllFeatures": "Alle Features anzeigen", + "CLI_CommandLineInterface": "CLI (Command Line Interface)", + "CLI_CommandLineInterfaceExplanation": "Enthält eine CLI, mit der Sie die Erstellung neuer Projekte und das Hinzufügen neuer Module automatisieren können.", + "StartupTemplates": "Startvorlagen", + "StartupTemplatesExplanation": "Verschiedene Startvorlagen bieten eine vollständig konfigurierte Lösung, um Ihre Entwicklung zu beschleunigen.", + "BasedOnFamiliarTools": "Basierend auf vertrauten Tools", + "BasedOnFamiliarToolsExplanation": "Aufbauend auf und integriert mit beliebten Tools, die Sie bereits kennen. Geringe Lernkurve, einfache Anpassung, komfortable Entwicklung.", + "ORMIndependent": "ORM-unabhängig", + "ORMIndependentExplanation": "Das Kernframework ist ORM-/datenbankunabhängig und kann mit jeder Datenquelle arbeiten. Entity Framework Core- und MongoDB-Anbieter sind bereits verfügbar.", + "Features": "Entdecken Sie die ABP Framework-Features", + "ABPCLI": "ABP CLI", + "Modularity": "Modularität", + "BootstrapTagHelpers": "Bootstrap Tag Helpers", + "DynamicForms": "Dynamische Formulare", + "BundlingMinification": "Bundling & Minification", + "BackgroundJobs": "Background Jobs", + "BackgroundJobsExplanation": "Definieren Sie einfache Klassen, um Jobs im Hintergrund in der Warteschlange auszuführen. Verwenden Sie den integrierten Jobmanager oder integrieren Sie Ihren eigenen. Hangfire & RabbitMQ -Integrationen sind bereits verfügbar.", + "DDDInfrastructure": "DDD-Infrastruktur", + "DomainDrivenDesignInfrastructure": "Domain Driven Design-Infrastruktur", + "AutoRESTAPIs": "Auto REST APIs", + "DynamicClientProxies": "Dynamische Client-Proxies", + "DistributedEventBus": "Distributed Event Bus", + "DistributedEventBusWithRabbitMQIntegration": "Distributed Event Bus mit RabbitMQ-Integration", + "TestInfrastructure": "Test-Infrastruktur", + "AuditLoggingEntityHistories": "Audit Logging & Entity Histories", + "ObjectToObjectMapping": "Object to Object Mapping", + "ObjectToObjectMappingExplanation": " Object to Object Mapping Abstraktion mit AutoMapper-Integration.", + "EmailSMSAbstractions": "E-Mail & SMS Abstraktionen", + "EmailSMSAbstractionsWithTemplatingSupport": "E-Mail- und SMS-Abstraktionen mit Vorlagenunterstützung", + "Localization": "Lokalisierung", + "SettingManagement": "Einstellungsverwaltung", + "ExtensionMethods": "Erweiterungsmethoden", + "ExtensionMethodsHelpers": "Erweiterungsmethoden & Helfer", + "AspectOrientedProgramming": "Aspektorientierte Programmierung", + "DependencyInjection": "Dependency Injection", + "DependencyInjectionByConventions": "Dependency Injection durch Konventionen", + "ABPCLIExplanation": "ABP CLI (Command Line Interface) ist ein Befehlszeilenprogramm zum Ausführen einiger gängiger Vorgänge für ABP-basierte Lösungen.", + "ModularityExplanation": "ABP bietet eine vollständige Infrastruktur zum Erstellen eigener Anwendungsmodule, die Entities, Services, Datenbankintegration, APIs, UI-Komponenten usw. enthalten können.", + "MultiTenancyExplanation": "Das ABP-Framework unterstützt nicht nur die Entwicklung von Multi-Mandantenanwendungen, sondern macht Ihren Code von der Mandantenfähigkeit auch weitgehend unabhängig.", + "MultiTenancyExplanation2": "Kann den aktuellen Mandanten automatisch ermitteln und Daten verschiedener Mandanten voneinander isolieren.", + "MultiTenancyExplanation3": "Unterstützt einzelne Datenbank-, Datenbank-pro-Mandanten- und Hybrid-Ansätze.", + "MultiTenancyExplanation4": "Sie konzentrieren sich auf Ihren geschäftsspezifischen Code und lassen das Framework die Mandantenfähigkeit für Sie übernehmen.", + "BootstrapTagHelpersExplanation": "Anstatt die sich wiederholenden Details von Bootstrap-Komponenten manuell zu schreiben, verwenden Sie die Tag-Helper von ABP, um diese zu vereinfachen und dabei die Vorteile von Intellisense zu nutzen. Sie können Bootstrap weitherhin verwenden, wann immer Sie es benötigen.", + "DynamicFormsExplanation": "Helfer für dynamische Formular- und Input-Tags können das vollständige Formular anhand einer C#-Klasse als Model erstellen.", + "AuthenticationAuthorizationExplanation": "Umfangreiche Authentifizierungs- und Autorisierungsoptionen, die in ASP.NET Core Identity & IdentityServer4 integriert sind. Bietet ein erweiterbares und detailliertes Berechtigungssystem.", + "CrossCuttingConcernsExplanation": "Wiederholen Sie sich nicht, um all diese allgemeinen Dinge immer wieder zu implementieren. Konzentrieren Sie sich auf Ihren geschäftsspezifischen Code und lassen Sie ihn von ABP durch Konventionen automatisieren.", + "DatabaseConnectionTransactionManagement": "Datenbankverbindungs- und Transaktionsmanagement", + "CorrelationIdTracking": "Correlation-ID-Verfolgung", + "BundlingMinificationExplanation": "ABP bietet ein einfaches, dynamisches, leistungsstarkes, modulares und integriertes Bundling- und Minification-System.", + "VirtualFileSystemnExplanation": "Das virtuelle Dateisystem ermöglicht die Verwaltung von Dateien, die physisch nicht auf dem Dateisystem (Datenträger) vorhanden sind. Es wird hauptsächlich verwendet, um Dateien (js, css, image, cshtml ...) in Assemblys einzubetten und sie zur Laufzeit wie physische Dateien zu verwenden.", + "ThemingExplanation": "Mit dem Theming-System können Sie Ihre Anwendung & Module Theme-unabhängig entwickeln, indem Sie eine Reihe gemeinsamer Basisbibliotheken und Layouts definieren, die auf dem neuesten Bootstrap-Framework basieren.", + "DomainDrivenDesignInfrastructureExplanation": "Eine vollständige Infrastruktur zum Erstellen von mehrschichtigen Anwendungen basierend auf den Domain Driven Design Entwurfsmustern und -prinzipien;", + "Specification": "Specification", + "Repository": "Repository", + "DomainService": "Domain Service", + "ValueObject": "Value Object", + "ApplicationService": "Application Service", + "DataTransferObject": "Data Transfer Object", + "AggregateRootEntity": "Aggregate Root, Entity", + "AutoRESTAPIsExplanation": "ABP kann Ihre Anwendungsservices gemäß Konvention automatisch als API-Controller konfigurieren.", + "DynamicClientProxiesExplanation": "Verwenden Sie Ihre APIs ganz einfach in JavaScript- und C#-Clients.", + "DistributedEventBusWithRabbitMQIntegrationExplanation": "Veröffentlichen und konsumieren Sie Distributed Events einfach mithilfe des integrierten Distributed Event Bus mit verfügbarer RabbitMQ-Integration.", + "TestInfrastructureExplanation": "Das Framework wurde unter Berücksichtigung von Unit- und Integrationstests entwickelt. Bietet Ihnen Basisklassen, um es einfacher zu machen. Startvorlagen werden mit vorkonfiguriert Tests geliefert.", + "AuditLoggingEntityHistoriesExplanation": "Integriertes Audit Logging für geschäftskritische Anwendungen. Audit Logging auf Request-, Service-, und Methodenebene sowie Entity-Historien mit Details auf Property-Ebene.", + "EmailSMSAbstractionsWithTemplatingSupportExplanation": "IEmailSender- und ISmsSender-Abstraktionen entkoppeln Ihre Anwendungslogik von der Infrastruktur. Das erweiterte E-Mail-Vorlagensystem ermöglicht das Erstellen und Lokalisieren von E-Mail-Vorlagen und deren einfache Verwendung bei Bedarf.", + "LocalizationExplanation": "Das Lokalisierungssystem ermöglicht das Erstellen von Ressourcen in einfachen JSON-Dateien und die Lokalisierung Ihrer Benutzeroberfläche. Es unterstützt erweiterte Szenarien wie Vererbung, Erweiterungen und JavaScript-Integration und ist vollständig mit dem Lokalisierungssystem von AspNet Core kompatibel.", + "SettingManagementExplanation": "Definieren Sie Einstellungen für Ihre Anwendung und erhalten Sie zur Laufzeit Werte basierend auf der aktuellen Konfiguration, dem Mandanten und dem Benutzer.", + "ExtensionMethodsHelpersExplanation": "Wiederholen Sie sich nicht einmal für triviale Codeteile. Erweiterungen und Helfer für Standardtypen machen Ihren Code viel sauberer und einfacher zu schreiben.", + "AspectOrientedProgrammingExplanation": "Bietet eine komfortable Infrastruktur zum Erstellen dynamischer Proxys und zum Implementieren der aspektorientierten Programmierung. Fangen Sie eine Klasse ab und führen Sie Ihren Code vor und nach jeder Methodenausführung aus.", + "DependencyInjectionByConventionsExplanation": "Sie müssen Ihre Klassen nicht manuell für die Dependency Injection registrieren. Registriert gängige Servicetypen automatisch gemäß Konvention. Für andere Arten von Services können Sie Schnittstellen und Attribute verwenden, um dies einfacher gestalten und an Ort und Stelle zu ermöglichen.", + "DataFilteringExplanation": "Definieren und verwenden Sie Datenfilter, die automatisch angewendet werden, wenn Sie Entities aus der Datenbank abfragen. Soft Delete- und Multimandanten-Filter sind sofort verfügbar, wenn Sie einfache Schnittstellen implementieren.", + "PublishEvents": "Events veröffentlichen", + "HandleEvents": "Auf Events reagieren", + "AndMore": "und mehr...", + "Code": "Code", + "Result": "Resultat", + "SeeTheDocumentForMoreInformation": "Weitere Informationen finden Sie in der {0} -Dokumentation ", + "IndexPageHeroSection": "Open SourceWebanwendung
Framework
für ASP.Net Core", + "UiFramework": "UI-Framework", + "EmailAddress": "E-Mail-Adresse", + "Mobile": "Mobile", + "ReactNative": "React Native", + "Strong": "Stark", + "Complete": "Vollständig", + "BasedLayeringModel": "Based Layering Model", + "Microservice": "Microservice", + "Compatible": "Kompatibel", + "MeeTTheABPCommunityInfo": "Unsere Mission ist es, eine Umgebung zu schaffen, in der Entwickler sich gegenseitig mit Beiträgen, Tutorials, Fallstudien usw. helfen und Gleichgesinnte treffen können.", + "JoinTheABPCommunityInfo": "Beteiligen Sie sich an einer lebendigen Community und tragen Sie zum ABP Framework bei!", + "AllArticles": "Alle Beiträge", + "SubmitYourArticle": "Reichen Sie Ihren Beitrag ein", + "DynamicClientProxyDocument": "In der Dokumentation zu den Dynamischen Client-Proxies finden Sie Informationen zu JavaScript & C#.", + "EmailSMSAbstractionsDocument": "Weitere Informationen finden Sie in den Unterlagen E-Mail-Senden and SMS-Senden.", + "CreateProjectWizard": "Dieser Assistent erstellt ein neues Projekt aus der Startvorlage, die ordnungsgemäß konfiguriert ist, um Ihr Projekt zu starten.", + "TieredOption": "Erstellt eine Tiered Lösung, bei der Web- und HTTP-API-Ebenen physisch getrennt sind. Wenn diese Option nicht aktiviert ist, wird eine mehrschichtige Lösung erstellt, die weniger komplex und für die meisten Szenarien geeignet ist.", + "SeparateIdentityServerOption": "Trennt die Serverseite in zwei Anwendungen: Die erste ist für den Identitätsserver und die zweite für die serverseitige HTTP-API.", + "UseslatestPreVersion": "Verwendet die neueste Vorabversion", + "ReadTheDocumentation": "Lesen SieDie Dokumentation", + "Documentation": "Dokumentation", + "GettingStartedTutorial": "Erste Schritte Tutorial", + "ApplicationDevelopmentTutorial": "Tutorial zur Anwendungsentwicklung", + "TheStartupTemplate": "Die Startvorlage", + "InstallABPCLIInfo": "ABP CLI ist der schnellste Weg, um eine neue Lösung mit dem ABP-Framework zu starten. Installieren Sie die ABP-CLI über die Eingabeaufforderung:", + "DifferentLevelOfNamespaces": "Sie können verschiedene Ebenen von Namespaces verwenden; z.B. BookStore, Acme.BookStore or Acme.Retail.BookStore.", + "ABPCLIExamplesInfo": "Der Befehl new erstellt eine mehrschichtige MVC-Anwendung mit Entity Framework Core als Datenbankanbieter. Es gibt jedoch zusätzliche Optionen. Beispiele:", + "SeeCliDocumentForMoreInformation": "Weitere Optionen finden Sie im ABP CLI-Dokument oder wählen Sie oben die Registerkarte \"Direkter Download\".", + "Optional": "Optional", + "LocalFrameworkRef": "Behalten Sie die lokale Projektreferenz für die Framework-Pakete bei." + } +} \ No newline at end of file diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json index cb4a8d076c..492229d6bb 100644 --- a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json @@ -45,7 +45,7 @@ "CompleteArchitectureInfo": "Modern architecture to create maintainable software solutions.", "DomainDrivenDesignBasedLayeringModelExplanation": "Helps you to implement a DDD based layered architecture and build a maintainable code base.", "DomainDrivenDesignBasedLayeringModelExplanationCont": "Provides startup templates, abstractions, base classes, services, documentation and guides to help you to develop your application based on DDD patterns & principles.", - "MicroserviceCompatibleModelExplanation": "The core framework & pre-build modules are designed the microservice architecture in mind.", + "MicroserviceCompatibleModelExplanation": "The core framework & pre-build modules are designed with microservice architecture in mind.", "MicroserviceCompatibleModelExplanationCont": "Provides infrastructure, integrations, samples and documentation to implement microservice solutions easier, while it doesn\u2019t bring additional complexity if you want a monolithic application.", "ModularInfo": "ABP provides a module system that allows you to develop reusable application modules, tie into application lifecycle events, and express dependencies between core parts of your system.", "PreBuiltModulesThemes": "Pre-Built Modules & Themes", diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/es.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/es.json new file mode 100644 index 0000000000..76132f71ba --- /dev/null +++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/es.json @@ -0,0 +1,189 @@ +{ + "culture": "es", + "texts": { + "GetStarted": "", + "Create": "", + "NewProject": "", + "DirectDownload": "", + "ProjectName": "", + "ProjectType": "", + "DatabaseProvider": "", + "NTier": "", + "IncludeUserInterface": "", + "CreateNow": "", + "TheStartupProject": "", + "Tutorial": "", + "UsingCLI": "", + "SeeDetails": "", + "AbpShortDescription": "", + "SourceCodeUpper": "", + "LatestReleaseLogs": "", + "Infrastructure": "", + "Architecture": "", + "Modular": "", + "DontRepeatYourself": "", + "DeveloperFocused": "", + "FullStackApplicationInfrastructure": "", + "DomainDrivenDesign": "", + "DomainDrivenDesignExplanation": "", + "Authorization": "", + "AuthorizationExplanation": "", + "MultiTenancy": "", + "MultiTenancyExplanationShort": "", + "CrossCuttingConcerns": "", + "CrossCuttingConcernsExplanationShort": "", + "BuiltInBundlingMinification": "", + "BuiltInBundlingMinificationExplanation": "", + "VirtualFileSystem": "", + "VirtualFileSystemExplanation": "", + "Theming": "", + "ThemingExplanationShort": "", + "BootstrapTagHelpersDynamicForms": "", + "BootstrapTagHelpersDynamicFormsExplanation": "", + "HTTPAPIsDynamicProxies": "", + "HTTPAPIsDynamicProxiesExplanation": "", + "CompleteArchitectureInfo": "", + "DomainDrivenDesignBasedLayeringModelExplanation": "", + "DomainDrivenDesignBasedLayeringModelExplanationCont": "", + "MicroserviceCompatibleModelExplanation": "", + "MicroserviceCompatibleModelExplanationCont": "", + "ModularInfo": "", + "PreBuiltModulesThemes": "", + "PreBuiltModulesThemesExplanation": "", + "NuGetNPMPackages": "", + "NuGetNPMPackagesExplanation": "", + "ExtensibleReplaceable": "", + "ExtensibleReplaceableExplanation": "", + "CrossCuttingConcernsExplanation2": "", + "CrossCuttingConcernsExplanation3": "", + "AuthenticationAuthorization": "", + "ExceptionHandling": "", + "Validation": "", + "DatabaseConnection": "", + "TransactionManagement": "", + "AuditLogging": "", + "Caching": "", + "Multitenancy": "", + "DataFiltering": "", + "ConventionOverConfiguration": "", + "ConventionOverConfigurationExplanation": "", + "ConventionOverConfigurationExplanationList1": "", + "ConventionOverConfigurationExplanationList2": "", + "ConventionOverConfigurationExplanationList3": "", + "ConventionOverConfigurationExplanationList4": "", + "ConventionOverConfigurationExplanationList5": "", + "ConventionOverConfigurationExplanationList6": "", + "BaseClasses": "", + "BaseClassesExplanation": "", + "DeveloperFocusedExplanation": "", + "DeveloperFocusedExplanationCont": "", + "SeeAllFeatures": "", + "CLI_CommandLineInterface": "", + "CLI_CommandLineInterfaceExplanation": "", + "StartupTemplates": "", + "StartupTemplatesExplanation": "", + "BasedOnFamiliarTools": "", + "BasedOnFamiliarToolsExplanation": "", + "ORMIndependent": "", + "ORMIndependentExplanation": "", + "Features": "", + "ABPCLI": "", + "Modularity": "", + "BootstrapTagHelpers": "", + "DynamicForms": "", + "BundlingMinification": "", + "BackgroundJobs": "", + "BackgroundJobsExplanation": "", + "DDDInfrastructure": "", + "DomainDrivenDesignInfrastructure": "", + "AutoRESTAPIs": "", + "DynamicClientProxies": "", + "DistributedEventBus": "", + "DistributedEventBusWithRabbitMQIntegration": "", + "TestInfrastructure": "", + "AuditLoggingEntityHistories": "", + "ObjectToObjectMapping": "", + "ObjectToObjectMappingExplanation": "", + "EmailSMSAbstractions": "", + "EmailSMSAbstractionsWithTemplatingSupport": "", + "Localization": "", + "SettingManagement": "", + "ExtensionMethods": "", + "ExtensionMethodsHelpers": "", + "AspectOrientedProgramming": "", + "DependencyInjection": "", + "DependencyInjectionByConventions": "", + "ABPCLIExplanation": "", + "ModularityExplanation": "", + "MultiTenancyExplanation": "", + "MultiTenancyExplanation2": "", + "MultiTenancyExplanation3": "", + "MultiTenancyExplanation4": "", + "BootstrapTagHelpersExplanation": "", + "DynamicFormsExplanation": "", + "AuthenticationAuthorizationExplanation": "", + "CrossCuttingConcernsExplanation": "", + "DatabaseConnectionTransactionManagement": "", + "CorrelationIdTracking": "", + "BundlingMinificationExplanation": "", + "VirtualFileSystemnExplanation": "", + "ThemingExplanation": "", + "DomainDrivenDesignInfrastructureExplanation": "", + "Specification": "", + "Repository": "", + "DomainService": "", + "ValueObject": "", + "ApplicationService": "", + "DataTransferObject": "", + "AggregateRootEntity": "", + "AutoRESTAPIsExplanation": "", + "DynamicClientProxiesExplanation": "", + "DistributedEventBusWithRabbitMQIntegrationExplanation": "", + "TestInfrastructureExplanation": "", + "AuditLoggingEntityHistoriesExplanation": "", + "EmailSMSAbstractionsWithTemplatingSupportExplanation": "", + "LocalizationExplanation": "", + "SettingManagementExplanation": "", + "ExtensionMethodsHelpersExplanation": "", + "AspectOrientedProgrammingExplanation": "", + "DependencyInjectionByConventionsExplanation": "", + "DataFilteringExplanation": "", + "PublishEvents": "", + "HandleEvents": "", + "AndMore": "", + "Code": "", + "Result": "", + "SeeTheDocumentForMoreInformation": "", + "IndexPageHeroSection": "", + "UiFramework": "", + "EmailAddress": "", + "Mobile": "", + "ReactNative": "", + "Strong": "", + "Complete": "", + "BasedLayeringModel": "", + "Microservice": "", + "Compatible": "", + "MeeTTheABPCommunityInfo": "", + "JoinTheABPCommunityInfo": "", + "AllArticles": "", + "SubmitYourArticle": "", + "DynamicClientProxyDocument": "", + "EmailSMSAbstractionsDocument": "", + "CreateProjectWizard": "", + "TieredOption": "", + "SeparateIdentityServerOption": "", + "UseslatestPreVersion": "", + "ReadTheDocumentation": "", + "Documentation": "", + "GettingStartedTutorial": "", + "ApplicationDevelopmentTutorial": "", + "TheStartupTemplate": "", + "InstallABPCLIInfo": "", + "DifferentLevelOfNamespaces": "", + "ABPCLIExamplesInfo": "", + "SeeCliDocumentForMoreInformation": "", + "Optional": "", + "LocalFrameworkRef": "" + } +} \ No newline at end of file diff --git a/build/common.ps1 b/build/common.ps1 index 18019a154e..0afe55f120 100644 --- a/build/common.ps1 +++ b/build/common.ps1 @@ -16,7 +16,9 @@ $solutionPaths = @( "../modules/tenant-management", "../modules/audit-logging", "../modules/background-jobs", - "../modules/account" + "../modules/account", + "../modules/cms-kit", + "../modules/blob-storing-database" ) if ($full -eq "-f") @@ -29,6 +31,8 @@ if ($full -eq "-f") "../modules/blogging", "../templates/module/aspnet-core", "../templates/app/aspnet-core", + "../templates/console", + "../templates/wpf", "../abp_io/AbpIoLocalization" ) }else{ diff --git a/common.DotSettings b/common.DotSettings index 6f40d029a7..7edbd05e75 100644 --- a/common.DotSettings +++ b/common.DotSettings @@ -20,6 +20,17 @@ False False SQL + False + Never + Never + False + Never + Never + Never + Never + Never + True + True False False False diff --git a/common.props b/common.props index 4d5f1b934b..cc8cf10402 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ - - latest - 3.3.2 + + latest + 4.0.2 $(NoWarn);CS1591;CS0436 https://abp.io/assets/abp_nupkg.png https://abp.io/ @@ -13,4 +13,4 @@ - \ No newline at end of file + diff --git a/docs/en/API/Auto-API-Controllers.md b/docs/en/API/Auto-API-Controllers.md index 77819c48c9..e139c16d20 100644 --- a/docs/en/API/Auto-API-Controllers.md +++ b/docs/en/API/Auto-API-Controllers.md @@ -75,17 +75,48 @@ Configure(options => Then the route for getting a book will be '**/api/volosoft/book-store/book/{id}**'. This sample uses two-level root path, but you generally use a single level depth. -* Continues with the **normalized controller/service name**. Normalization removes 'AppService', 'ApplicationService' and 'Service' postfixes and converts it to **camelCase**. If your application service class name is 'BookAppService' then it becomes only '/book'. +* Continues with the **normalized controller/service name**. Normalization removes 'AppService', 'ApplicationService' and 'Service' postfixes and converts it to **kebab-case**. If your application service class name is 'ReadingBookAppService' then it becomes only '/reading-book'. * If you want to customize naming, then set the `UrlControllerNameNormalizer` option. It's a func delegate which allows you to determine the name per controller/service. * If the method has an '**id**' parameter then it adds '**/{id}**' ro the route. * Then it adds the action name if necessary. Action name is obtained from the method name on the service and normalized by; * Removing '**Async**' postfix. If the method name is 'GetPhonesAsync' then it becomes 'GetPhones'. * Removing **HTTP method prefix**. 'GetList', 'GetAll', 'Get', 'Put', 'Update', 'Delete', 'Remove', 'Create', 'Add', 'Insert', 'Post' and 'Patch' prefixes are removed based on the selected HTTP method. So, 'GetPhones' becomes 'Phones' since 'Get' prefix is a duplicate for a GET request. - * Converting the result to **camelCase**. + * Converting the result to **kebab-case**. * If the resulting action name is **empty** then it's not added to the route. If it's not empty, it's added to the route (like '/phones'). For 'GetAllAsync' method name it will be empty, for 'GetPhonesAsync' method name it will be 'phones'. * Normalization can be customized by setting the `UrlActionNameNormalizer` option. It's an action delegate that is called for every method. * If there is another parameter with 'Id' postfix, then it's also added to the route as the final route segment (like '/phoneId'). +#### Customizing the Route Calculation + +`IConventionalRouteBuilder` is used to build the route. It is implemented by the `ConventionalRouteBuilder` by default and works as explained above. You can replace/override this service to customize the route calculation strategy. + +#### Version 3.x Style Route Calculation + +The route calculation was different before the version 4.0. It was using camelCase conventions, while the ABP Framework version 4.0+ uses kebab-case. If you use the old route calculation strategy, follow one of the approaches; + +* Set `UseV3UrlStyle` to `true` in the options of the `options.ConventionalControllers.Create(...)` method. Example: + +````csharp +options.ConventionalControllers + .Create(typeof(BookStoreApplicationModule).Assembly, opts => + { + opts.UseV3UrlStyle = true; + }); +```` + +This approach effects only the controllers for the `BookStoreApplicationModule`. + +* Set `UseV3UrlStyle` to `true` for the `AbpConventionalControllerOptions` to set it globally. Example: + +```csharp +Configure(options => +{ + options.UseV3UrlStyle = true; +}); +``` + +Setting it globally effects all the modules in a modular application. + ## Service Selection Creating conventional HTTP API controllers are not unique to application services actually. diff --git a/docs/en/API/Dynamic-CSharp-API-Clients.md b/docs/en/API/Dynamic-CSharp-API-Clients.md index d92846f5e8..b1d71e0bb1 100644 --- a/docs/en/API/Dynamic-CSharp-API-Clients.md +++ b/docs/en/API/Dynamic-CSharp-API-Clients.md @@ -1,10 +1,23 @@ # Dynamic C# API Client Proxies -ABP can dynamically create C# API client proxies to call remote HTTP services (REST APIs). In this way, you don't need to deal with `HttpClient` and other low level HTTP features to call remote services and get results. +ABP can dynamically create C# API client proxies to call your remote HTTP services (REST APIs). In this way, you don't need to deal with `HttpClient` and other low level details to call remote services and get results. + +Dynamic C# proxies automatically handles the following stuff for you; + +* Maps C# **method calls** to remote server **HTTP calls** by considering the HTTP method, route, query string parameters, request payload and other details. +* **Authenticates** the HTTP Client by adding access token to the HTTP header. +* **Serializes** to and deserialize from JSON. +* Handles HTTP API **versioning**. +* Add **correlation id**, current **tenant** id and the current **culture** to the request. +* Properly **handles the error messages** sent by the server and throws proper exceptions. + +This system can be used by any type of .NET client to consume your HTTP APIs. ## Service Interface -Your service/controller should implement an interface that is shared between the server and the client. So, first define a service interface in a shared library project. Example: +Your service/controller should implement an interface that is shared between the server and the client. So, first define a service interface in a shared library project, typically in the `Application.Contracts` project if you've created your solution using the startup templates. + +Example: ````csharp public interface IBookAppService : IApplicationService @@ -13,7 +26,7 @@ public interface IBookAppService : IApplicationService } ```` -Your interface should implement the `IRemoteService` interface to be automatically discovered. Since the `IApplicationService` inherits the `IRemoteService` interface, the `IBookAppService` above satisfies this condition. +> Your interface should implement the `IRemoteService` interface to be automatically discovered. Since the `IApplicationService` inherits the `IRemoteService` interface, the `IBookAppService` above satisfies this condition. Implement this class in your service application. You can use [auto API controller system](Auto-API-Controllers.md) to expose the service as a REST API endpoint. @@ -55,6 +68,8 @@ public class MyClientAppModule : AbpModule `AddHttpClientProxies` method gets an assembly, finds all service interfaces in the given assembly, creates and registers proxy classes. +> The startup templates already comes pre-configured for the client proxy generation, in the `HttpApi.Client` project. + ### Endpoint Configuration `RemoteServices` section in the `appsettings.json` file is used to get remote service address by default. Simplest configuration is shown below: @@ -106,7 +121,7 @@ While you can inject `IBookAppService` like above to use the client proxy, you c ### AbpRemoteServiceOptions -`AbpRemoteServiceOptions` is automatically set from the `appsettings.json` by default. Alternatively, you can use `Configure` method to set or override it. Example: +`AbpRemoteServiceOptions` is automatically set from the `appsettings.json` by default. Alternatively, you can configure it in the `ConfigureServices` method of your [module](../Module-Development-Basics.md) to set or override it. Example: ````csharp public override void ConfigureServices(ServiceConfigurationContext context) @@ -162,4 +177,30 @@ context.Services.AddHttpClientProxies( Using `asDefaultServices: false` may only be needed if your application has already an implementation of the service and you do not want to override/replace the other implementation by your client proxy. -> If you disable `asDefaultServices`, you can only use `IHttpClientProxy` interface to use the client proxies. See the *IHttpClientProxy Interface* section above. \ No newline at end of file +> If you disable `asDefaultServices`, you can only use `IHttpClientProxy` interface to use the client proxies. See the *IHttpClientProxy Interface* section above. + +### Retry/Failure Logic & Polly Integration + +If you want to add retry logic for the failing remote HTTP calls for the client proxies, you can configure the `AbpHttpClientBuilderOptions` in the `PreConfigureServices` method of your module class. + +**Example: Use the [Polly](https://github.com/App-vNext/Polly) library to re-try 3 times on a failure** + +````csharp +public override void PreConfigureServices(ServiceConfigurationContext context) +{ + PreConfigure(options => + { + options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) => + { + clientBuilder.AddTransientHttpErrorPolicy(policyBuilder => + policyBuilder.WaitAndRetryAsync( + 3, + i => TimeSpan.FromSeconds(Math.Pow(2, i)) + ) + ); + }); + }); +} +```` + +This example uses the [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly) package. You also need to import the `Polly` namespace (`using Polly;`) to be able to use the `WaitAndRetryAsync` method. \ No newline at end of file diff --git a/docs/en/Application-Services.md b/docs/en/Application-Services.md index f48ff9cb5b..7fe9825f2a 100644 --- a/docs/en/Application-Services.md +++ b/docs/en/Application-Services.md @@ -342,12 +342,12 @@ public class DistrictAppService { } - protected override async Task DeleteByIdAsync(DistrictKey id) + protected async override Task DeleteByIdAsync(DistrictKey id) { await Repository.DeleteAsync(d => d.CityId == id.CityId && d.Name == id.Name); } - protected override async Task GetEntityByIdAsync(DistrictKey id) + protected async override Task GetEntityByIdAsync(DistrictKey id) { return await AsyncQueryableExecuter.FirstOrDefaultAsync( Repository.Where(d => d.CityId == id.CityId && d.Name == id.Name) @@ -400,7 +400,7 @@ public class MyPeopleAppService : CrudAppService { } - protected override async Task CheckDeletePolicyAsync() + protected async override Task CheckDeletePolicyAsync() { await AuthorizationService.CheckAsync("..."); } diff --git a/docs/en/AspNet-Boilerplate-Migration-Guide.md b/docs/en/AspNet-Boilerplate-Migration-Guide.md index c7cc8a9e53..f4c2ec712b 100644 --- a/docs/en/AspNet-Boilerplate-Migration-Guide.md +++ b/docs/en/AspNet-Boilerplate-Migration-Guide.md @@ -438,7 +438,7 @@ ABP Framework uses and extends ASP.NET Core's [distributed caching abstraction]( ### Logging -ASP.NET Boilerplate uses Castle Windsor's [logging facility](http://docs.castleproject.org/Windsor.Logging-Facility.ashx) as an abstraction and supports multiple logging providers including Log4Net (the default one comes with the startup projects) and Serilog. You typically property-inject the logger: +ASP.NET Boilerplate uses Castle Windsor's [logging facility](https://github.com/castleproject/Windsor/blob/master/docs/logging-facility.md) as an abstraction and supports multiple logging providers including Log4Net (the default one comes with the startup projects) and Serilog. You typically property-inject the logger: ````csharp using Castle.Core.Logging; //1: Import Logging namespace diff --git a/docs/en/Authentication/Social-External-Logins.md b/docs/en/Authentication/Social-External-Logins.md index 309d4977a5..e80e53d4bd 100644 --- a/docs/en/Authentication/Social-External-Logins.md +++ b/docs/en/Authentication/Social-External-Logins.md @@ -1,32 +1,3 @@ # Social/External Logins -The [Account Module](../Modules/Account.md) has already configured to handle social or external logins out of the box. You can follow the ASP.NET Core documentation to add a social/external login provider to your application. - -## Example: Facebook Authentication - -Follow the [ASP.NET Core Facebook integration document](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins) to support the Facebook login for your application. - -#### Add the NuGet Package - -Add the [Microsoft.AspNetCore.Authentication.Facebook](https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.Facebook) package to your project. Based on your architecture, this can be `.Web`, `.IdentityServer` (for tiered setup) or `.Host` project. - -#### Configure the Provider - -Use the `.AddFacebook(...)` extension method in the `ConfigureServices` method of your [module](../Module-Development-Basics.md), to configure the client: - -````csharp -context.Services.AddAuthentication() - .AddFacebook(facebook => - { - facebook.AppId = "..."; - facebook.AppSecret = "..."; - facebook.Scope.Add("email"); - facebook.Scope.Add("public_profile"); - }); -```` - -> It would be a better practice to use the `appsettings.json` or the ASP.NET Core User Secrets system to store your credentials, instead of a hard-coded value like that. Follow the [Microsoft's document](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins) to learn the user secrets usage. - -## Angular UI - -Beginning from the v3.1, the Angular UI uses authorization code flow (as a best practice) to authenticate the user by redirecting to the MVC UI login page. So, even if you are using the Angular UI, social/external login integration is same as explained above and it will work out of the box. \ No newline at end of file +> This document has been moved. See the [Account Module](../Modules/Account.md) documentation. \ No newline at end of file diff --git a/docs/en/Authorization.md b/docs/en/Authorization.md index eef4237039..fbb71bb3d4 100644 --- a/docs/en/Authorization.md +++ b/docs/en/Authorization.md @@ -234,7 +234,7 @@ context When you write this code inside your permission definition provider, it finds the "role deletion" permission of the [Identity Module](Modules/Identity.md) and disabled the permission, so no one can delete a role on the application. -> Tip: It is better to check the value returned by the `GetPermissionOrNull` method since it may return null if the given permission was not defined. +> Tip: It is better to check the value returned by the `GetPermissionOrNull` method since it may return null if the given permission was not defined. ## IAuthorizationService @@ -280,21 +280,11 @@ public async Task CreateAsync(CreateAuthorDto input) ## Check a Permission in JavaScript -You may need to check a policy/permission on the client side. +See the following documents to learn how to re-use the authorization system on the client side: -### MVC UI - -For ASP.NET Core MVC / Razor Pages applications, you can use the `abp.auth` API. - -**Example: Check if a given permission has been granted for the current user** - -```js -abp.auth.isGranted('MyPermissionName'); -``` - -### Angular UI - -See the [permission management document](UI/Angular/Permission-Management.md) for the Angular UI. +* [ASP.NET Core MVC / Razor Pages UI: Authorization](UI/AspNetCore/JavaScript-API/Auth.md) +* [Angular UI Authorization](UI/Angular/Permission-Management.md) +* [Blazor UI Authorization](UI/Blazor/Authorization.md) ## Permission Management @@ -354,7 +344,7 @@ public class SystemAdminPermissionValueProvider : PermissionValueProvider public override string Name => "SystemAdmin"; - public override async Task + public async override Task CheckAsync(PermissionValueCheckContext context) { if (context.Principal?.FindFirst("User_Type")?.Value == "SystemAdmin") @@ -406,5 +396,5 @@ This is already done for the startup template integration tests. ## See Also * [Permission Management Module](Modules/Permission-Management.md) -* [ASP.NET Core MVC / Razor Pages JavaScript Auth API](API/JavaScript-API/Auth.md) +* [ASP.NET Core MVC / Razor Pages JavaScript Auth API](UI/AspNetCore/JavaScript-API/Auth.md) * [Permission Management in Angular UI](UI/Angular/Permission-Management.md) diff --git a/docs/en/Background-Workers.md b/docs/en/Background-Workers.md index c8a617efec..2e1b9d2a90 100644 --- a/docs/en/Background-Workers.md +++ b/docs/en/Background-Workers.md @@ -54,7 +54,7 @@ public class PassiveUserCheckerWorker : AsyncPeriodicBackgroundWorkerBase Timer.Period = 600000; //10 minutes } - protected override async Task DoWorkAsync( + protected async override Task DoWorkAsync( PeriodicBackgroundWorkerContext workerContext) { Logger.LogInformation("Starting: Setting status of inactive users..."); diff --git a/docs/en/Blog-Posts/2020-05-08 v2_7_Release/Post.md b/docs/en/Blog-Posts/2020-05-08 v2_7_Release/Post.md index b6c1d3f952..c09b0eb75c 100644 --- a/docs/en/Blog-Posts/2020-05-08 v2_7_Release/Post.md +++ b/docs/en/Blog-Posts/2020-05-08 v2_7_Release/Post.md @@ -16,7 +16,7 @@ ABP.IO Platform is rapidly growing and we are getting more and more contribution ### Object Extending System -In the last few releases, we've mostly focused on providing ways to extend existing modules when you use them as NuGet/NPM Packages. +In the last few releases, we've mostly focused on providing ways to extend existing modules when you use them as NuGet/NPM Packages. The Object Extending System allows module developers to create extensible modules and allows application developers to customize and extend a module easily. @@ -43,7 +43,7 @@ ObjectExtensionManager.Instance options.Attributes.Add(new RequiredAttribute()); options.Attributes.Add( new StringLengthAttribute(32) { - MinimumLength = 6 + MinimumLength = 6 } ); }); @@ -121,7 +121,7 @@ Just create a class derived from the `ExceptionSubscriber` class in your applica ````csharp public class MyExceptionSubscriber : ExceptionSubscriber { - public override async Task HandleAsync(ExceptionNotificationContext context) + public async override Task HandleAsync(ExceptionNotificationContext context) { //TODO... } @@ -244,4 +244,4 @@ We ([Volosoft](https://volosoft.com/) - the core team behind the ABP.IO platform [ABP Framework](https://abp.io/) provides all the infrastructure and application independent framework features to make you more productive, focus on your own business code and implement software development best practices. It provides you a well defined and comfortable development experience without repeating yourself. -[ABP Commercial](https://commercial.abp.io/) provides pre-built functionalities, themes and tooling to save your time if your requirements involve these functionalities in addition to the premium support for the framework and the pre-built modules. \ No newline at end of file +[ABP Commercial](https://commercial.abp.io/) provides pre-built functionalities, themes and tooling to save your time if your requirements involve these functionalities in addition to the premium support for the framework and the pre-built modules. diff --git a/docs/en/Blog-Posts/2020-10-15 v3_3_Preview/POST.md b/docs/en/Blog-Posts/2020-10-15 v3_3_Preview/POST.md index b42e17e865..4e19a294c1 100644 --- a/docs/en/Blog-Posts/2020-10-15 v3_3_Preview/POST.md +++ b/docs/en/Blog-Posts/2020-10-15 v3_3_Preview/POST.md @@ -2,6 +2,32 @@ We have released the [ABP Framework](https://abp.io/) (and the [ABP Commercial](https://commercial.abp.io/)) `3.3.0-rc.1` today. This blog post introduces the new features and important changes in the new version. +## Get Started with the 3.3 RC.1 + +If you want to try the version `3.3.0-rc.1` today, follow the steps below; + +1) **Upgrade** the ABP CLI to the version `3.3.0-rc.1` using a command line terminal: + +````bash +dotnet tool update Volo.Abp.Cli -g --version 3.3.0-rc.1 +```` + +**or install** if you haven't installed before: + +````bash +dotnet tool install Volo.Abp.Cli -g --version 3.3.0-rc.1 +```` + +2) Create a **new application** with the `--preview` option: + +````bash +abp new BookStore --preview +```` + +See the [ABP CLI documentation](https://docs.abp.io/en/abp/3.3/CLI) for all the available options. + +> You can also use the *Direct Download* tab on the [Get Started](https://abp.io/get-started) page by selecting the Preview checkbox. + ## What's new with the ABP Framework 3.3 ### The Blazor UI @@ -20,19 +46,19 @@ We are still working on the fundamentals. So, the next version may introduce bre #### Breaking Changes on the Blazor UI -There are some breaking changes with the Blazor UI. If you've built an application and upgrade it, your application might not properly work. See [the migration guide](https://github.com/abpframework/abp/blob/dev/docs/en/Migration-Guides/BlazorUI-3_3.md) for the changes you need to do after upgrading your application. +There are some breaking changes with the Blazor UI. If you've built an application and upgrade it, your application might not properly work. See [the migration guide](https://docs.abp.io/en/abp/3.3/Migration-Guides/BlazorUI-3_3) for the changes you need to do after upgrading your application. ### Automatic Validation for AntiForgery Token for HTTP APIs -Starting with the version 3.3, all your HTTP API endpoints are **automatically protected** against CSRF attacks, unless you disable it for your application. +Starting with the version 3.3, all your HTTP API endpoints are **automatically protected** against CSRF attacks, unless you disable it for your application. So, no configuration needed, just upgrade the ABP Framework. -[See the documentation](https://github.com/abpframework/abp/blob/dev/docs/en/CSRF-Anti-Forgery.md) to understand why you need it and how ABP Framework solves the problem. +[See the documentation](https://docs.abp.io/en/abp/3.3/CSRF-Anti-Forgery) to if you want to understand why you need it and how ABP Framework solves the problem. ### Rebus Integration Package for the Distributed Event Bus [Rebus](https://github.com/rebus-org/Rebus) describes itself as "Simple and lean service bus implementation for .NET". There are a lot of integration packages like RabbitMQ and Azure Service Bus for the Rebus. The new [Volo.Abp.EventBus.Rebus](https://www.nuget.org/packages/Volo.Abp.EventBus.Rebus) package allows you to use the Rebus as the [distributed event bus](https://docs.abp.io/en/abp/latest/Distributed-Event-Bus) for the ABP Framework. -See [the documentation](https://github.com/abpframework/abp/blob/dev/docs/en/Distributed-Event-Bus-Rebus-Integration.md) to learn how to use Rebus with the ABP Framework. +See [the documentation](https://docs.abp.io/en/abp/3.3/Distributed-Event-Bus-Rebus-Integration) to learn how to use Rebus with the ABP Framework. ### Async Repository LINQ Extension Methods @@ -180,7 +206,14 @@ There are still missing features and modules. However, we are working on it to h #### Breaking Changes on the Blazor UI -There are some breaking changes with the Blazor UI. If you've built an application and upgrade it, your application might not properly work. See the [ABP Commercial Blazor UI v 3.3 Migration Guide](https://github.com/abpio/abp-commercial-docs/blob/dev/en/migration-guides/blazor-ui-3_3.md) for the changes you need to do after upgrading your application. +There are some breaking changes with the Blazor UI. If you've built an application and upgrade it, your application might not properly work. See the [ABP Commercial Blazor UI v 3.3 Migration Guide](https://docs.abp.io/en/commercial/3.3/migration-guides/blazor-ui-3_3) for the changes you need to do after upgrading your application. + +#### Known Issues + +When you create a new project, profile management doesn't work, you get an exception because it can't find the `/libs/cropperjs/css/cropper.min.css` file. To fix the issue; + +* Add `"@volo/account": "^3.3.0-rc.1"` to the `package.json` in the `.Host` project. +* Run `yarn` (or `npm install`), then `gulp` on a command line terminal in the root folder of the `.Host` project. ### Multi-Tenant Social Logins @@ -216,7 +249,7 @@ Besides the new features introduced in this post, we've done a lot of small othe ## New Articles -The core ABP Framework team & the community continue to publish new articles on the ABP Community web site. The recently published articles are; +The core ABP Framework team & the community continue to publish new articles on the [ABP Community](https://community.abp.io/) web site. The recently published articles are; * [Replacing Email Templates and Sending Emails](https://community.abp.io/articles/replacing-email-templates-and-sending-emails-jkeb8zzh) (by [@EngincanV](https://community.abp.io/members/EngincanV)) * [How to Add Custom Properties to the User Entity](https://community.abp.io/articles/how-to-add-custom-property-to-the-user-entity-6ggxiddr) (by [@berkansasmaz](https://community.abp.io/members/berkansasmaz)) diff --git a/docs/en/Blog-Posts/2020-10-27 v3_3_Release_Stable/POST.md b/docs/en/Blog-Posts/2020-10-27 v3_3_Release_Stable/POST.md new file mode 100644 index 0000000000..4f7507cbfd --- /dev/null +++ b/docs/en/Blog-Posts/2020-10-27 v3_3_Release_Stable/POST.md @@ -0,0 +1,47 @@ +# ABP Framework & ABP Commercial 3.3 Final Have Been Released + +ABP Framework & ABP Commercial 3.3.0 have been released today. + +Since all the new features are already explained in details with the [3.3 RC Announcement Post](https://blog.abp.io/abp/ABP-Framework-ABP-Commercial-v3.3-RC-Have-Been-Released), I will not repeat all the details again. Please read [the RC post](https://blog.abp.io/abp/ABP-Framework-ABP-Commercial-v3.3-RC-Have-Been-Released) for **new feature and changes** you may need to do for your solution while upgrading to the version 3.3. + +## Creating New Solutions + +You can create a new solution with the ABP Framework version 3.3 by either using the `abp new` command or using the **direct download** tab on the [get started page](https://abp.io/get-started). + +> See the [getting started document](https://docs.abp.io/en/abp/latest/Getting-Started) for details. + +## How to Upgrade an Existing Solution + +### Install/Update the ABP CLI + +First of all, install the ABP CLI or upgrade to the latest version. + +If you haven't installed yet: + +````bash +dotnet tool install -g Volo.Abp.Cli +```` + +To update an existing installation: + +```bash +dotnet tool update -g Volo.Abp.Cli +``` + +### ABP UPDATE Command + +[ABP CLI](https://docs.abp.io/en/abp/latest/CLI) provides a handy command to update all the ABP related NuGet and NPM packages in your solution with a single command: + +````bash +abp update +```` + +Run this command in the root folder of your solution. After the update command, check [the RC blog post](https://blog.abp.io/abp/ABP-Framework-ABP-Commercial-v3.3-RC-Have-Been-Released) to learn if you need to make any changes in your solution. + +> You may want to see the new [upgrading document](https://docs.abp.io/en/abp/latest/Upgrading). + +## About the Next Version: 4.0 + +The next version will be 4.0 and it will be mostly related to completing the Blazor UI features and upgrading the ABP Framework & ecosystem to the .NET 5.0. + +The goal is to complete the version 4.0 with a stable Blazor UI with the fundamental features implemented and publish it just after the Microsoft lunches .NET 5 in this November. The planned 4.0 preview release date is November 11th. \ No newline at end of file diff --git a/docs/en/Blog-Posts/2020-11-12 v4_0_Preview/POST.md b/docs/en/Blog-Posts/2020-11-12 v4_0_Preview/POST.md new file mode 100644 index 0000000000..acd3c70b2f --- /dev/null +++ b/docs/en/Blog-Posts/2020-11-12 v4_0_Preview/POST.md @@ -0,0 +1,143 @@ +# ABP Framework 4.0 RC Has Been Published based on .NET 5.0! + +Today, we have released the [ABP Framework](https://abp.io/) (and the [ABP Commercial](https://commercial.abp.io/)) `4.0.0-rc.1` that is based on the **.NET 5.0**. This blog post introduces the new features and important changes in the new version. + +> **The planned release date for the [4.0.0 final](https://github.com/abpframework/abp/milestone/45) version is November 26, 2020**. + +## Get Started with the 4.0 RC.1 + +If you want to try the version `4.0.0-rc.1` today, follow the steps below; + +1) **Upgrade** the ABP CLI to the version `4.0.0-rc.1` using a command line terminal: + +````bash +dotnet tool update Volo.Abp.Cli -g --version 4.0.0-rc.1 +```` + +**or install** if you haven't installed before: + +````bash +dotnet tool install Volo.Abp.Cli -g --version 4.0.0-rc.1 +```` + +2) Create a **new application** with the `--preview` option: + +````bash +abp new BookStore --preview +```` + +See the [ABP CLI documentation](https://docs.abp.io/en/abp/3.3/CLI) for all the available options. + +> You can also use the *Direct Download* tab on the [Get Started](https://abp.io/get-started) page by selecting the **Preview checkbox**. + +## Migrating From 3.x to 4.0 + +The version 4.0 comes with some major changes including the **migration from .NET Core 3.1 to .NET 5.0**. + +We've prepared a **detailed [migration document](https://docs.abp.io/en/abp/4.0/Migration-Guides/Abp-4_0)** to explain all the changes and the actions you need to take while upgrading your existing solutions. + +## What's new with the ABP Framework 4.0 + +### The Blazor UI + +The Blazor UI is now stable and officially supported. The [web application development tutorial](https://docs.abp.io/en/abp/4.0/Tutorials/Part-1?UI=Blazor) has been updated based on the version 4.0. + +#### abp bundle command + +Introducing the `abp bundle` CLI command to manage static JavaScript & CSS file dependencies of a Blazor application. This command is currently used to add the dependencies to the `index.html` file in the dependency order by respecting to modularity. In the next version it will automatically unify & minify the files. The documentation is being prepared. + +#### Removed the JQuery & Bootstrap JavaScript + +Removed JQuery & Bootstrap JavaScript dependencies for the Blazor UI. + +>There are some other changes in the startup template and some public APIs. Follow the [Migration Guide](https://docs.abp.io/en/abp/4.0/Migration-Guides/Abp-4_0) to apply changes for existing solutions that you're upgrading from the version 3.3. While we will continue to make improvements add new features, we no longer make breaking changes on the existing APIs until the version 5.0. + +#### Others + +A lot of minor and major improvements have been done for the Blazor UI. Some of them are listed below: + +* Implemented `IComponentActivator` to resolve the component from the `IServiceProvider`. So, you can now inject dependencies into the constructor of your razor component. +* Introduced the `AbpComponentBase` base class that you derive your components from. It has useful base properties that you can use in your pages/components. +* Introduced `IUiNotificationService` service to show toast notifications on the UI. +* Improved the `IUiMessageService` to show message & confirmation dialogs. + +### System.Text.Json + +ABP Framework 4.0 uses the System.Text.Json by default as the JSON serialization library. It, actually, using a hybrid approach: Continues to use the Newtonsoft.Json when it needs to use the features not supported by the System.Text.Json. + +Follow the [Migration Guide](https://docs.abp.io/en/abp/4.0/Migration-Guides/Abp-4_0) to learn how to configure to use the Newtonsoft.Json for some specific types or switch back to the Newtonsoft.Json as the default JSON serializer. + +### Identity Server 4 Upgrade + +ABP Framework upgrades the [IdentityServer4](https://www.nuget.org/packages/IdentityServer4) library from 3.x to 4.1.1 with the ABP Framework version 4.0. IdentityServer 4.x has a lot of changes. Some of them are **breaking changes in the data structure**. + +Follow the [Migration Guide](https://docs.abp.io/en/abp/4.0/Migration-Guides/Abp-4_0) to upgrade existing solutions. + +### Creating a New Module Inside the Application + +ABP CLI has now a command to create a new module and add it to an existing solution. In this way, you can create modular applications easier than before. + +Example: Create a *ProductManagement* module into your solution. + +````bash +abp add-module ProductManagement --new --add-to-solution-file +```` + +Execute this command in a terminal in the root folder of your solution. If you don't specify the `--add-to-solution-file` option, then the module projects will not be added to the main solution, but the project references still be added. In this case, you need to open the module's solution to develop the module. + +See the [CLI document](https://docs.abp.io/en/abp/4.0/CLI) for other options. + +### WPF Startup Template + +Introducing the WPF startup template for the ABP Framework. Use the ABP CLI new command to create a new WPF application: + +````bash +abp new MyWpfApp -t wpf +```` + +This is a minimalist, empty project template that is integrated to the ABP Framework. + +### New Languages + +**Thanks to the contributors** from the ABP Community, the framework modules and the startup template have been localized to **German** language by [Alexander Pilhar](https://github.com/alexanderpilhar) & [Nico Lachmuth](https://github.com/tntwist). + +### Other Notes + +* Upgraded to Angular 11. +* Since [Mongo2Go](https://github.com/Mongo2Go/Mongo2Go) library not supports transactions, you can use transactions in unit tests for MongoDB. + +## What's new with the ABP Commercial 4.0 + +### The Blazor UI + +The Blazor UI for the ABP Commercial is also becomes stable and feature rich with the version 4.0; + +* [ABP Suite](https://commercial.abp.io/tools/suite) now supports to generate CRUD pages for the Blazor UI. +* Completed the [Lepton Theme](https://commercial.abp.io/themes) for the Blazor UI. +* Implemented the [File Management](https://commercial.abp.io/modules/Volo.FileManagement) module for the Blazor UI. + +### The ABP Suite + +While creating create/edit modals with a navigation property, we had two options: A dropdown to select the target entity and a modal to select the entity by searching with a data table. + +Dropdown option now supports **lazy load, search and auto-complete**. In this way, selecting a navigation property becomes much easier and supports large data sets on the dropdown. + +**Example: Select an author while creating a new book** + +![abp-suite-auto-complete-dropdown](abp-suite-auto-complete-dropdown.png) + +With the new version, you can **disable backend code generation** on CRUD page generation. This is especially useful if you want to regenerate the page with a different UI framework, but don't want to regenerate the server side code. + +### Identity Server Management UI Revised + +Completely revised the Identity Server Management UI based on the IDS 4.x changes. + +## About the Next Release + +The next feature version, `4.1.0`, will mostly focus on completing the missing documents, fixing bugs, performance optimizations and improving the Blazor UI features. The planned preview release date for the version `4.1.0` is December 10 and the final (stable) version release date is December 24. + +Follow the [GitHub milestones](https://github.com/abpframework/abp/milestones) for all the planned ABP Framework version release dates. + +## Feedback + +Please check out the ABP Framework 4.0.0 RC and [provide feedback](https://github.com/abpframework/abp/issues/new) to help us to release a more stable version. **The planned release date for the [4.0.0 final](https://github.com/abpframework/abp/milestone/45) version is November 26**. diff --git a/docs/en/Blog-Posts/2020-11-12 v4_0_Preview/abp-suite-auto-complete-dropdown.png b/docs/en/Blog-Posts/2020-11-12 v4_0_Preview/abp-suite-auto-complete-dropdown.png new file mode 100644 index 0000000000..2021ef42bd Binary files /dev/null and b/docs/en/Blog-Posts/2020-11-12 v4_0_Preview/abp-suite-auto-complete-dropdown.png differ diff --git a/docs/en/CLI.md b/docs/en/CLI.md index 8713bc9019..d51dd91b5d 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -41,6 +41,7 @@ Here, the list of all available commands before explaining their details: * **`login`**: Authenticates on your computer with your [abp.io](https://abp.io/) username and password. * **`logout`**: Logouts from your computer if you've authenticated before. * **`build`**: Builds a GIT repository and depending repositories or a single .NET solution. +* **`bundle`**: Generates script and style references for an ABP Blazor project. ### help @@ -106,6 +107,7 @@ abp new Acme.BookStore * `--create-solution-folder` or `-csf`: Specifies if the project will be in a new folder in the output folder or directly the output folder. * `--connection-string` or `-cs`: Overwrites the default connection strings in all `appsettings.json` files. The default connection string is `Server=localhost;Database=MyProjectName;Trusted_Connection=True;MultipleActiveResultSets=true` for EF Core and it is configured to use the SQL Server. If you want to use the EF Core, but need to change the DBMS, you can change it as [described here](Entity-Framework-Core-Other-DBMS.md) (after creating the solution). * `--local-framework-ref --abp-path`: Uses local projects references to the ABP framework instead of using the NuGet packages. This can be useful if you download the ABP Framework source code and have a local reference to the framework from your application. +* `--no-random-port`: Uses template's default ports. ### update @@ -159,6 +161,8 @@ abp add-package Volo.Abp.MongoDB Adds a [multi-package application module](Modules/Index) to a solution by finding all packages of the module, finding related projects in the solution and adding each package to the corresponding project in the solution. +It can also create a new module for your solution and add it to your solution. See `--new-template` option. + > A business module generally consists of several packages (because of layering, different database provider options or other reasons). Using `add-module` command dramatically simplifies adding a module to a solution. However, each module may require some additional configurations which is generally indicated in the documentation of the related module. Usage @@ -167,21 +171,29 @@ Usage abp add-module [options] ```` -Example: +Examples: ```bash abp add-module Volo.Blogging ``` -* This example add the Volo.Blogging module to the solution. +* This example adds the `Volo.Blogging` module to the solution. + +```bash +abp add-module ProductManagement --new --add-to-solution-file +``` + +* This command creates a fresh new module customized for your solution (named `ProductManagement`) and adds it to your solution. + #### Options * `--solution` or `-s`: Specifies the solution (.sln) file path. If not specified, CLI tries to find a .sln file in the current directory. * `--skip-db-migrations`: For EF Core database provider, it automatically adds a new code first migration (`Add-Migration`) and updates the database (`Update-Database`) if necessary. Specify this option to skip this operation. * `-sp` or `--startup-project`: Relative path to the project folder of the startup project. Default value is the current folder. -* `--with-source-code`: Downloads the source code of the module to your solution folder and uses local project references instead of NuGet/NPM packages. -* `--add-to-solution-file`: Adds the downloaded module to your solution file, so you will also see the projects of the module when you open the solution on a IDE. (only available when `--with-source-code` is used.) +* `--new`: Creates a fresh new module (customized for your solution) and adds it to your solution. +* `--with-source-code`: Downloads the source code of the module to your solution folder and uses local project references instead of NuGet/NPM packages. This options is always `True` if `--new` is used. +* `--add-to-solution-file`: Adds the downloaded/created module to your solution file, so you will also see the projects of the module when you open the solution on a IDE. (only available when `--with-source-code` is `True`.) ### get-source @@ -383,10 +395,27 @@ abp build --build-name "prod" --dotnet-build-arguments "\"--no-dependencies\"" #### Options -* ```--working-directory``` or ```-w```: Specifies the working directory. This option is useful when the command is executed outside of a GIT repository or when executing directory doesn't contain a .NET solution file. +* ```--working-directory``` or ```-wd```: Specifies the working directory. This option is useful when the command is executed outside of a GIT repository or when executing directory doesn't contain a .NET solution file. * ```--build-name``` or ```-n```: Specifies a name for the build. This option is useful when same repository is used for more than one different builds. * ```--dotnet-build-arguments``` or ```-a```: Arguments to pass ```dotnet build``` when building project files. This parameter must be passed like ```"\"{params}\""``` . * ```--force``` or ```-f```: Forces to build projects even they are not changed from the last successful build. For more details, see [build command documentation](CLI-BuildCommand.md). + +#### bundle + +This command generates script and style references for an ABP Blazor project and updates the **index.html** file. It helps developers to manage dependencies required by ABP modules easily. In order ```bundle``` command to work, its **executing directory** or passed ```--working-directory``` parameter's directory must contain a Blazor project file(*.csproj). + +Usage: + +````bash +abp bundle [options] +```` + +#### Options + +* ```--working-directory``` or ```-wd```: Specifies the working directory. This option is useful when executing directory doesn't contain a Blazor project file. +* ```--force``` or ```-f```: Forces to build project before generating references. + +For more details about managing style and script references in Blazor apps, see [Managing Global Scripts & Styles](UI/Blazor/Global-Scripts-Styles.md) \ No newline at end of file diff --git a/docs/en/CSRF-Anti-Forgery.md b/docs/en/CSRF-Anti-Forgery.md index ad838e3548..720edc5924 100644 --- a/docs/en/CSRF-Anti-Forgery.md +++ b/docs/en/CSRF-Anti-Forgery.md @@ -25,7 +25,7 @@ ABP Framework provides `[AbpValidateAntiForgeryToken]` and `[AbpAutoValidateAnti ABP Framework also automates the following infrastructure; -* Server side sets a **special cookie**, named `XSRF-TOKEN` by default, that is used make the antiforgery token value available to the browser. This is **done automatically** (by the [application configuration](Application-Configuration.md) endpoint). Nothing to do in the client side. +* Server side sets a **special cookie**, named `XSRF-TOKEN` by default, that is used make the antiforgery token value available to the browser. This is **done automatically** (by the [application configuration](API/Application-Configuration.md) endpoint). Nothing to do in the client side. * In the client side, it reads the token from the cookie and sends it in the **HTTP header** (named `RequestVerificationToken` by default). This is implemented for all the supported UI types. * Server side validates the antiforgery token **only for same and cross site requests** made by the browser. It bypasses the validation for non-browser clients. @@ -117,3 +117,31 @@ You don't need to make anything unless you need to change the `AntiforgeryOption }) export class AppModule {} ``` + +**Note:** XSRF-TOKEN is only valid if both frontend application and APIs run on the same domain. Therefore, when you make a request, you should use a relative path. + +For example, let's say your APIs is hosted at `https://testdomain.com/ws` +and your angular application is hosted at `https://testdomain.com/admin` + +So if your API request should look like this `https://testdomain.com/ws/api/identity/users` + +your `environment.prod.ts` has to be as follows: + +```typescript +export const environment = { + production: true, + // .... + apis: { + default: { + url: '/ws', // <- just use the context root here + // ... + }, + }, +} as Config.Environment; +``` + +Let's talk about why. + +First, take a look at [Angular's code](https://github.com/angular/angular/blob/master/packages/common/http/src/xsrf.ts#L81) + +It does not intercept any request that starts with `http://` or `https://`. There is a good reason for that. Any cross-site request does not need this token for security. This verification is only valid if the request is made to the same domain from which the web page is served. So, simply put, if you serve everything from a single domain, you just use a relative path. \ No newline at end of file diff --git a/docs/en/Community-Articles/2020-04-19-Customize-the-SignIn-Manager/POST.md b/docs/en/Community-Articles/2020-04-19-Customize-the-SignIn-Manager/POST.md index d46049526d..1342407880 100644 --- a/docs/en/Community-Articles/2020-04-19-Customize-the-SignIn-Manager/POST.md +++ b/docs/en/Community-Articles/2020-04-19-Customize-the-SignIn-Manager/POST.md @@ -1,6 +1,6 @@ # How to Customize the SignIn Manager for ABP Applications -After creating a new application using the [application startup template](https://docs.abp.io/en/abp/latest/Startup-Templates/Application), you may want extend or change the default behavior of the SignIn Manager for your authentication and registration flow needs. ABP [Account Module](https://docs.abp.io/en/abp/latest/Modules/Account) uses the [Identity Management Module](https://docs.abp.io/en/abp/latest/Modules/Identity) for SignIn Manager and the [Identity Management Module](https://docs.abp.io/en/abp/latest/Modules/Identity) uses default [Microsoft Identity SignIn Manager](https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs) ([see here](https://github.com/abpframework/abp/blob/be32a55449e270d2d456df3dabdc91f3ffdd4fa9/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs#L17)). +After creating a new application using the [application startup template](https://docs.abp.io/en/abp/latest/Startup-Templates/Application), you may want extend or change the default behavior of the SignIn Manager for your authentication and registration flow needs. ABP [Account Module](https://docs.abp.io/en/abp/latest/Modules/Account) uses the [Identity Management Module](https://docs.abp.io/en/abp/latest/Modules/Identity) for SignIn Manager and the [Identity Management Module](https://docs.abp.io/en/abp/latest/Modules/Identity) uses default [Microsoft Identity SignIn Manager](https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs) ([see here](https://github.com/abpframework/abp/blob/be32a55449e270d2d456df3dabdc91f3ffdd4fa9/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs#L17)). To write your Custom SignIn Manager, you need to extend [Microsoft Identity SignIn Manager](https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs) class and register it to the DI container. @@ -27,7 +27,7 @@ public class CustomSignInManager : Microsoft.AspNetCore.Identity.SignInManager It is important to use **Volo.Abp.Identity.IdentityUser** type for SignInManager to inherit, not the AppUser of your application. +> It is important to use **Volo.Abp.Identity.IdentityUser** type for SignInManager to inherit, not the AppUser of your application. Afterwards you can override any of the SignIn Manager methods you need and add new methods and properties needed for your authentication or registration flow. @@ -38,7 +38,7 @@ In this case we'll be overriding the `GetExternalLoginInfoAsync` method which is A good way to override a method is copying its [source code](https://github.com/dotnet/aspnetcore/blob/c56aa320c32ee5429d60647782c91d53ac765865/src/Identity/Core/src/SignInManager.cs#L638-L674). In this case, we will be using a minorly modified version of the source code which explicitly shows the namespaces of the methods and properties to help better understanding of the concept. ````csharp -public override async Task GetExternalLoginInfoAsync(string expectedXsrf = null) +public async override Task GetExternalLoginInfoAsync(string expectedXsrf = null) { var auth = await Context.AuthenticateAsync(Microsoft.AspNetCore.Identity.IdentityConstants.ExternalScheme); var items = auth?.Properties?.Items; @@ -93,4 +93,4 @@ PreConfigure(identityBuilder => ## The Source Code -You can find the source code of the completed example [here](https://github.com/abpframework/abp-samples/tree/master/Authentication-Customization). \ No newline at end of file +You can find the source code of the completed example [here](https://github.com/abpframework/abp-samples/tree/master/Authentication-Customization). diff --git a/docs/en/Community-Articles/2020-08-07-Passwordless-Authentication/POST.md b/docs/en/Community-Articles/2020-08-07-Passwordless-Authentication/POST.md index b31ea023f2..9489c004bd 100644 --- a/docs/en/Community-Articles/2020-08-07-Passwordless-Authentication/POST.md +++ b/docs/en/Community-Articles/2020-08-07-Passwordless-Authentication/POST.md @@ -33,7 +33,7 @@ namespace PasswordlessAuthentication.Web } //We need to override this method as well. - public override async Task GetUserModifierAsync(string purpose, UserManager manager, TUser user) + public async override Task GetUserModifierAsync(string purpose, UserManager manager, TUser user) { var userId = await manager.GetUserIdAsync(user); @@ -105,7 +105,7 @@ namespace PasswordlessAuthentication.Web.Pages UserManager = userManager; _userRepository = userRepository; } - + public ActionResult OnGet() { if (!CurrentUser.IsAuthenticated) @@ -115,15 +115,15 @@ namespace PasswordlessAuthentication.Web.Pages return Page(); } - + //added for passwordless authentication public async Task OnPostGeneratePasswordlessTokenAsync() { var adminUser = await _userRepository.FindByNormalizedUserNameAsync("admin"); - + var token = await UserManager.GenerateUserTokenAsync(adminUser, "PasswordlessLoginProvider", "passwordless-auth"); - + PasswordlessLoginUrl = Url.Action("Login", "Passwordless", new {token = token, userId = adminUser.Id.ToString()}, Request.Scheme); @@ -238,7 +238,7 @@ namespace PasswordlessAuthentication.Web.Controllers return Redirect("/"); } - + private static IEnumerable CreateClaims(IUser user, IEnumerable roles) { var claims = new List @@ -272,4 +272,4 @@ That's all! We created a passwordless login with 7 steps. ## Source Code -The completed sample is available on [GitHub repository](https://github.com/abpframework/abp-samples/tree/master/PasswordlessAuthentication). \ No newline at end of file +The completed sample is available on [GitHub repository](https://github.com/abpframework/abp-samples/tree/master/PasswordlessAuthentication). diff --git a/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/POST.md b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/POST.md new file mode 100644 index 0000000000..f1387b2a50 --- /dev/null +++ b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/POST.md @@ -0,0 +1,46 @@ +# How to add a new language to your ABP project? + +Adding a new language to your ABP project is pretty simple. Let's add the German language to our ABP project: + + + +1. Go to your solution's root folder and write the following CLI command. This command will generate an empty translation file from English. + ```bash + abp translate -c de-DE + ``` + + Check out for [the complete supported culture codes](https://docs.microsoft.com/en-us/bingmaps/rest-services/common-parameters-and-types/supported-culture-codes). + (For internal development `D:\Github\abp` and `D:\Github\volo\abp`) + +2. Fill the `target` fields in your target language. + + ![Fill target fields](language-target.png) + +3. Copy `abp-translation.json` your solution's root folder (Do not change the filename!) + +4. Run the following command. This command will create the necessary `json` files. + ```bash + abp translate --apply + ``` + +5. Open your solution and add the new language to the language list. To do this; + + * open `MyProjectNameDomainModule.cs` and in `ConfigureServices` you'll find `Configure`. If you have `HttpApi.Host` project then you need to add this in `MyProjectNameHttpApiHostModule.cs` + + ``` + options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de")); + ``` + + ![Add to languages](add-to-languages.png) + + The last parameter is the flag icon. You can find the list of flag icons on https://flagicons.lipis.dev/ + + 6. The last step is running the DbMigrator project. It will seed the database for the new language. + ![The database table](database-table.png) + + + +Close the IIS Express / Kestrel to invalidate the language cache and run the project. You will see the new language on your website. + +![See the final result](website-new-language.png) + diff --git a/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/add-to-languages.png b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/add-to-languages.png new file mode 100644 index 0000000000..1dda317685 Binary files /dev/null and b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/add-to-languages.png differ diff --git a/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/database-table.png b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/database-table.png new file mode 100644 index 0000000000..2d512fabeb Binary files /dev/null and b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/database-table.png differ diff --git a/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/language-target.png b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/language-target.png new file mode 100644 index 0000000000..7b5f104003 Binary files /dev/null and b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/language-target.png differ diff --git a/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/website-new-language.png b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/website-new-language.png new file mode 100644 index 0000000000..1e04841983 Binary files /dev/null and b/docs/en/Community-Articles/2020-11-02-How-To-Add-New-Language/website-new-language.png differ diff --git a/docs/en/Contribution/Index.md b/docs/en/Contribution/Index.md index 83ec0bf05d..07dc73ab24 100644 --- a/docs/en/Contribution/Index.md +++ b/docs/en/Contribution/Index.md @@ -2,31 +2,36 @@ ABP is an [open source](https://github.com/abpframework) and community driven project. This guide is aims to help anyone wants to contribute to the project. -## community.abp.io +## ABP Community Website -If you want to write articles or "how to" guides related to the ABP Framework and ASP.NET Core, please submit your article to the [community.abp.io](https://community.abp.io/) web site. +If you want to write **articles** or **how to guides** related to the ABP Framework and ASP.NET Core, please submit your article to the [community.abp.io](https://community.abp.io/) website. ## Code Contribution -You can always send pull requests to the Github repository. +You can always send pull requests to the GitHub repository. -- Clone the [ABP repository](https://github.com/abpframework/abp/) from Github. -- Make the required changes. +- Clone the [ABP repository](https://github.com/abpframework/abp/) from GitHub. +- Build the repository using the `/build/build-all.ps1 -f` for one time. +- Make the necessary changes, including unit/integration tests. - Send a pull request. +> When you open a solution in Visual Studio, you may need to execute `dotnet restore` in the root folder of the solution for one time, after it is fully opened in the Visual Studio. This is needed since VS can't properly resolves local references to projects out of the solution. + +### GitHub Issues + Before making any change, please discuss it on the [Github issues](https://github.com/abpframework/abp/issues). In this way, no other developer will work on the same issue and your PR will have a better chance to be accepted. -### Bug Fixes & Enhancements +#### Bug Fixes & Enhancements You may want to fix a known bug or work on a planned enhancement. See [the issue list](https://github.com/abpframework/abp/issues) on Github. -### Feature Requests +#### Feature Requests If you have a feature idea for the framework or modules, [create an issue](https://github.com/abpframework/abp/issues/new) on Github or attend to an existing discussion. Then you can implement it if it's embraced by the community. ## Document Translation -You may want to translate the complete [documentation](https://abp.io/documents/) (including this one) to your mother language. If so, follow these steps: +You may want to translate the complete [documentation](https://docs.abp.io) (including this one) to your mother language. If so, follow these steps: * Clone the [ABP repository](https://github.com/abpframework/abp/) from Github. * To add a new language, create a new folder inside the [docs](https://github.com/abpframework/abp/tree/master/docs) folder. Folder names can be "en", "es", "fr", "tr" and so on based on the language (see [all culture codes](https://msdn.microsoft.com/en-us/library/hh441729.aspx)). @@ -35,9 +40,9 @@ You may want to translate the complete [documentation](https://abp.io/documents/ There are some fundamental documents need to be translated before publishing a language on the [ABP documentation web site](https://docs.abp.io): -* Getting Started documents -* Tutorials -* CLI +* Index (Home) +* Getting Started +* Web Application Development Tutorial A new language is published after these minimum translations have been completed. diff --git a/docs/en/Customizing-Application-Modules-Overriding-Services.md b/docs/en/Customizing-Application-Modules-Overriding-Services.md index b8706eea61..ab6f29816b 100644 --- a/docs/en/Customizing-Application-Modules-Overriding-Services.md +++ b/docs/en/Customizing-Application-Modules-Overriding-Services.md @@ -29,7 +29,7 @@ public class TestAppService : IIdentityUserAppService, ITransientDependency } ```` -The dependency injection system allows to register multiple services for the same interface. The last registered one is used when the interface is injected. It is a good practice to explicitly replace the service. +The dependency injection system allows to register multiple services for the same interface. The last registered one is used when the interface is injected. It is a good practice to explicitly replace the service. Example: @@ -59,7 +59,6 @@ In most cases, you will want to change one or a few methods of the current imple ### Example: Overriding an Application Service ````csharp -//[RemoteService(IsEnabled = false)] // If you use dynamic controller feature you can disable remote service. Prevent creating duplicate controller for the application service. [Dependency(ReplaceServices = true)] [ExposeServices(typeof(IIdentityUserAppService), typeof(IdentityUserAppService), typeof(MyIdentityUserAppService))] public class MyIdentityUserAppService : IdentityUserAppService @@ -76,7 +75,7 @@ public class MyIdentityUserAppService : IdentityUserAppService { } - public override async Task CreateAsync(IdentityUserCreateDto input) + public async override Task CreateAsync(IdentityUserCreateDto input) { if (input.PhoneNumber.IsNullOrWhiteSpace()) { @@ -109,33 +108,33 @@ public class MyIdentityUserManager : IdentityUserManager { public MyIdentityUserManager( IdentityUserStore store, - IIdentityRoleRepository roleRepository, + IIdentityRoleRepository roleRepository, IIdentityUserRepository userRepository, - IOptions optionsAccessor, + IOptions optionsAccessor, IPasswordHasher passwordHasher, - IEnumerable> userValidators, - IEnumerable> passwordValidators, + IEnumerable> userValidators, + IEnumerable> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, - ILogger logger, - ICancellationTokenProvider cancellationTokenProvider) : + ILogger logger, + ICancellationTokenProvider cancellationTokenProvider) : base(store, roleRepository, - userRepository, - optionsAccessor, - passwordHasher, - userValidators, + userRepository, + optionsAccessor, + passwordHasher, + userValidators, passwordValidators, - keyNormalizer, - errors, - services, - logger, + keyNormalizer, + errors, + services, + logger, cancellationTokenProvider) { } - public override async Task CreateAsync(IdentityUser user) + public async override Task CreateAsync(IdentityUser user) { if (user.PhoneNumber.IsNullOrWhiteSpace()) { @@ -182,7 +181,7 @@ namespace MyProject.Controllers } - public override async Task SendPasswordResetCodeAsync( + public async override Task SendPasswordResetCodeAsync( SendPasswordResetCodeDto input) { Logger.LogInformation("Your custom logic..."); @@ -197,6 +196,15 @@ This example replaces the `AccountController` (An API Controller defined in the **`[ExposeServices(typeof(AccountController))]` is essential** here since it registers this controller for the `AccountController` in the dependency injection system. `[Dependency(ReplaceServices = true)]` is also recommended to clear the old registration (even the ASP.NET Core DI system selects the last registered one). +In addition, The `AccountController` will be removed from [`ApplicationModel`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.applicationmodels.applicationmodel.controllers) because it defines `ExposeServicesAttribute`. If you don't want to remove it, you can configure `AbpAspNetCoreMvcOptions`: + +```csharp +Configure(options => +{ + options.IgnoredControllersOnModelExclusion.AddIfNotContains(typeof(AccountController)); +}); +``` + ### Overriding Other Classes Overriding controllers, framework services, view component classes and any other type of classes registered to dependency injection can be overridden just like the examples above. @@ -214,7 +222,7 @@ Assuming that you've already added a `SocialSecurityNumber` as described in the You can use the [object extension system](Object-Extensions.md) to add the property to the `IdentityUserDto`. Write this code inside the `YourProjectNameDtoExtensions` class comes with the application startup template: ````csharp -ObjectExtensionManager.Instance +ObjectExtensionManager.Instance .AddOrUpdateProperty( "SocialSecurityNumber" ); @@ -286,8 +294,8 @@ ObjectExtensionManager.Instance .AddOrUpdateProperty( new[] { - typeof(IdentityUserDto), - typeof(IdentityUserCreateDto), + typeof(IdentityUserDto), + typeof(IdentityUserCreateDto), typeof(IdentityUserUpdateDto) }, "SocialSecurityNumber" diff --git a/docs/en/Data-Access.md b/docs/en/Data-Access.md index a37f77eb65..7ba85956b9 100644 --- a/docs/en/Data-Access.md +++ b/docs/en/Data-Access.md @@ -1,15 +1,13 @@ # Data Access -## Database Providers - -ABP framework was designed as database agnostic. It can work any type of data source by the help of the [repository](Repositories.md) and [unit of work](Unit-Of-Work.md) abstractions. However, currently the following providers are implemented: +ABP framework was designed as database agnostic. It can work any type of data source by the help of the [repository](Repositories.md) and [unit of work](Unit-Of-Work.md) abstractions. Currently, the following providers are implemented as official: * [Entity Framework Core](Entity-Framework-Core.md) (works with [various DBMS and providers](https://docs.microsoft.com/en-us/ef/core/providers/).) * [MongoDB](MongoDB.md) * [Dapper](Dapper.md) -More providers will be added in the future. - ## See Also -* [Connection Strings](Connection-Strings.md) \ No newline at end of file +* [Connection Strings](Connection-Strings.md) +* [Data Seeding](Data-Seeding.md) +* [Data Filtering](Data-Filtering.md) \ No newline at end of file diff --git a/docs/en/Data-Filtering.md b/docs/en/Data-Filtering.md index 626719b2fc..6df738cf18 100644 --- a/docs/en/Data-Filtering.md +++ b/docs/en/Data-Filtering.md @@ -32,6 +32,8 @@ namespace Acme.BookStore > `ISoftDelete` filter is enabled by default and you can not get deleted entities from database unless you explicitly disable it. See the `IDataFilter` service below. +> Soft-delete entities can be hard-deleted when you use `HardDeleteAsync` method on the repositories. + ### IMultiTenant [Multi-tenancy](Multi-Tenancy.md) is an efficient way of creating SaaS applications. Once you create a multi-tenant application, you typically want to isolate data between tenants. Implement `IMultiTenant` interface to make your entity "multi-tenant aware". diff --git a/docs/en/Domain-Driven-Design-Implementation-Guide.md b/docs/en/Domain-Driven-Design-Implementation-Guide.md new file mode 100644 index 0000000000..9341df703b --- /dev/null +++ b/docs/en/Domain-Driven-Design-Implementation-Guide.md @@ -0,0 +1,1978 @@ +# Implementing Domain Driven Design + +## Introduction + +This is a **practical guide** for implementing the Domain Driven Design (DDD). While the implementation details rely on the ABP Framework infrastructure, core concepts, principles and patterns are applicable in any kind of solution, even if it is not a .NET solution. + +### Goals + +The goals of this document are to + +* **Introduce and explain** the DDD architecture, concepts, principles, patterns and building blocks. +* Explain the **layered architecture** & solution structure offered by the ABP Framework. +* Introduce **explicit rules** to implement DDD patterns and best practices by giving **concrete examples**. +* Show what **ABP Framework provides** you as the infrastructure for implementing DDD in a proper way. +* And finally, provide **suggestions** based on software development **best practices** and our experiences to create a **maintainable codebase**. + +### Simple Code! + +> **Playing football** is very **simple**, but **playing simple football** is the **hardest thing** there is. +> — Johan Cruyff + +If we take this famous quote for programming, we can say; + +> **Writing code** is very **simple**, but **writing simple code** is the **hardest thing** there is. +> — ??? + +In this document, we will introduce **simple rules**, those are **easy to implement**. + +Once your **application grows**, it will be **hard to follow** these rules. Sometimes you find **breaking rules** will save you time in a short term. However, the saved time in the short term will bring much **more time loss** in the middle and long term. Your code base becomes **complicated** and hard to maintain. Most of the business applications are **re-written** just because you **can't maintain** it anymore. + +If you **follow the rules and best practices**, your code base will be simpler and easier to maintain. Your application **reacts to changes** faster. + +## What is the Domain Driven Design? + +Domain-driven design (DDD) is an approach to software development for **complex** needs by connecting the implementation to an **evolving** model; + +DDD is suitable for **complex domains** and **large-scale** applications rather than simple CRUD applications. It focuses on the **core domain logic** rather than the infrastructure details. It helps to build a **flexible**, modular and **maintainable** code base. + +### OOP & SOLID + +Implementing DDD highly relies on the Object Oriented Programming (OOP) and [SOLID](https://en.wikipedia.org/wiki/SOLID) principles. Actually, it **implements** and **extends** these principles. So, a **good understanding** of OOP & SOLID helps you a lot while truly implementing the DDD. + +### DDD Layers & Clean Architecture + +There are four fundamental layers of a Domain Driven Based Solution; + +![domain-driven-design-layers](images/domain-driven-design-layers.png) + +**Business Logic** places into two layers, the *Domain layer* and the *Application Layer*, while they contain different kinds of business logic; + +* **Domain Layer** implements the core, use-case independent business logic of the domain/system. +* **Application Layer** implements the use cases of the application based on the domain. A use case can be thought as a user interaction on the User Interface (UI). +* **Presentation Layer** contains the UI elements (pages, components) of the application. +* **Infrastructure Layer** supports other layer by implementing the abstractions and integrations to 3rd-party library and systems. + +The same layering can be shown as the diagram below and known as the **Clean Architecture**, or sometimes the **Onion Architecture**: + +![domain-driven-design-clean-architecture](images/domain-driven-design-clean-architecture.png) + +In the Clean Architecture, each layer only **depends on the layer directly inside it**. The most independent layer is shown in the most inner circle and it is the Domain Layer. + +### Core Building Blocks + +DDD mostly **focuses on the Domain & Application Layers** and ignores the Presentation and Infrastructure. They are seen as *details* and the business layers should not depend on them. + +That doesn't mean the Presentation and Infrastructure layers are not important. They are very important. UI frameworks and database providers have their own rules and best practices that you need to know and apply. However these are not in the topics of DDD. + +This section introduces the essential building blocks of the Domain & Application Layers. + +#### Domain Layer Building Blocks + +* **Entity**: An [Entity](Entities.md) is an object with its own properties (state, data) and methods that implements the business logic that is executed on these properties. An entity is represented by its unique identifier (Id). Two entity object with different Ids are considered as different entities. +* **Value Object**: A [Value Object](Value-Objects.md) is another kind of domain object that is identified by its properties rather than a unique Id. That means two Value Objects with same properties are considered as the same object. Value objects are generally implemented as immutable and mostly are much simpler than the Entities. +* **Aggregate & Aggregate Root**: An [Aggregate](Entities.md) is a cluster of objects (entities and value objects) bound together by an **Aggregate Root** object. The Aggregate Root is a specific type of an entity with some additional responsibilities. +* **Repository** (interface): A [Repository](Repositories.md) is a collection-like interface that is used by the Domain and Application Layers to access to the data persistence system (the database). It hides the complexity of the DBMS from the business code. Domain Layer contains the `interface`s of the repositories. +* **Domain Service**: A [Domain Service](Domain-Services.md) is a stateless service that implements core business rules of the domain. It is useful to implement domain logic that depends on multiple aggregate (entity) type or some external services. +* **Specification**: A [Specification](Specifications.md) is used to define named, reusable and combinable filters for entities and other business objects. +* **Domain Event**: A [Domain Event](Event-Bus.md) is a way of informing other services in a loosely coupled manner, when a domain specific event occurs. + +#### Application Layer Building Blocks + +* **Application Service**: An [Application Service](Application-Services.md) is a stateless service that implements use cases of the application. An application service typically gets and returns DTOs. It is used by the Presentation Layer. It uses and coordinates the domain objects to implement the use cases. A use case is typically considered as a Unit Of Work. +* **Data Transfer Object (DTO)**: A [DTO](Data-Transfer-Objects.md) is a simple object without any business logic that is used to transfer state (data) between the Application and Presentation Layers. +* **Unit of Work (UOW)**: A [Unit of Work](Unit-Of-Work.md) is an atomic work that should be done as a transaction unit. All the operations inside a UOW should be committed on success or rolled back on a failure. + +## Implementation: The Big Picture + +### Layering of a .NET Solution + +The picture below shows a Visual Studio Solution created using the ABP's [application startup template](Startup-Templates/Application.md): + +![domain-driven-design-vs-solution](images/domain-driven-design-vs-solution.png) + +The solution name is `IssueTracking` and it consists of multiple projects. The solution is layered by considering **DDD principles** as well as **development** and **deployment** practicals. The sub sections below explains the projects in the solution; + +> Your solution structure may be slightly different if you choose a different UI or Database provider. However, the Domain and Application layers will be same and this is the essential point for the DDD perspective. See the [Application Startup Template](Startup-Templates/Application.md) document if you want to know more about the solution structure. + +#### The Domain Layer + +The Domain Layer is splitted into two projects; + +* `IssueTracking.Domain` is the **essential domain layer** that contains all the **building blocks** (entities, value objects, domain services, specifications, repository interfaces, etc.) introduced before. +* `IssueTracking.Domain.Shared` is a thin project that contains some types those belong to the Domain Layer, but shared with all other layers. For example, it may contain some constants and `enum`s related to the Domain Objects but need to be **reused by other layers**. + +#### The Application Layer + +The Application Layer is also splitted into two projects; + +* `IssueTracking.Application.Contracts` contains the application service **interfaces** and the **DTO**s used by these interfaces. This project can be shared by the client applications (including the UI). +* `IssueTracking.Application` is the **essential application layer** that **implements** the interfaces defined in the Contracts project. + +#### The Presentation Layer + +* `IssueTracking.Web` is an ASP.NET Core MVC / Razor Pages application for this example. This is the only executable application that serves the application and the APIs. + +> ABP Framework also supports different kind of UI frameworks including [Angular](UI/Angular/Quick-Start.md) and [Blazor](UI/Blazor/Overall.md). In these cases, the `IssueTracking.Web` doesn't exist in the solution. Instead, an `IssueTracking.HttpApi.Host` application will be in the solution to serve the HTTP APIs as a standalone endpoint to be consumed by the UI applications via HTTP API calls. + +#### The Remote Service Layer + +* `IssueTracking.HttpApi` project contains HTTP APIs defined by the solution. It typically contains MVC `Controller`s and related models, if available. So, you write your HTTP APIs in this project. + +> Most of the time, API Controllers are just wrappers around the Application Services to expose them to the remote clients. Since ABP Framework's [Automatic API Controller System](API/Auto-API-Controllers.md) **automatically configures and exposes your Application Services as API Controllers**, you typically don't create Controllers in this project. However, the startup solution includes it for the cases you need to manually create API controllers. + +* `IssueTracking.HttpApi.Client` project is useful when you have a C# application that needs to consume your HTTP APIs. Once the client application references this project, it can directly [inject](Dependency-Injection.md) & use the Application Services. This is possible by the help of the ABP Framework's [Dynamic C# Client API Proxies System](API/Dynamic-CSharp-API-Clients.md). + +> There is a Console Application in the `test` folder of the solution, named `IssueTracking.HttpApi.Client.ConsoleTestApp`. It simply uses the `IssueTracking.HttpApi.Client` project to consume the APIs exposed by the application. It is just a demo application and you can safely delete it. You can even delete the `IssueTracking.HttpApi.Client` project if you think that you don't need to them. + +#### The Infrastructure Layer + +In a DDD implementation, you may have a single Infrastructure project to implement all the abstractions and integrations, or you may have different projects for each dependency. + +We suggest a balanced approach; Create separate projects for main infrastructure dependencies (like Entity Framework Core) and a common infrastructure project for other infrastructure. + +ABP's startup solution has two projects for the Entity Framework Core integration; + +* `IssueTracking.EntityFrameworkCore` is the essential integration package for the EF Core. Your application's `DbContext`, database mappings, implementations of the repositories and other EF Core related stuff are located here. +* `IssueTracking.EntityFrameworkCore.DbMigrations` is a special project to manage the Code First database migrations. There is a separate `DbContext` in this project to track the migrations. You typically don't touch this project much except you need to create a new database migration or add an [application module](Modules/Index.md) that has some database tables and naturally requires to create a new database migration. + +> You may wonder why there are two projects for the EF Core. It is mostly related to [modularity](Module-Development-Basics.md). Each module has its own independent `DbContext` and your application has also one `DbContext`. `DbMigrations` project contains a **union** of the modules to track and apply a **single migration path**. While most of the time you don't need to know it, you can see the [EF Core migrations](Entity-Framework-Core-Migrations.md) document for more information. + +#### Other Projects + +There is one more project, `IssueTracking.DbMigrator`, that is a simple Console Application that **migrates** the database schema and **[seeds](Data-Seeding.md) the initial** data when you execute it. It is a useful **utility application** that you can use it in development as well as in production environment. + +### Dependencies of the Projects in the Solution + +The diagram below shows the essential dependencies (project references) between the projects in the solution (`IssueTracking.` part is not shown to be simple) + +![domain-driven-design-project-relations](images/domain-driven-design-project-relations.png) + +The projects have been explained before. Now, we can explain the reasons of the dependencies; + +* `Domain.Shared` is the project that all other projects directly or indirectly depend on. So, all the types in this project are available to all projects. +* `Domain` only depends on the `Domain.Shared` because it is already a (shared) part of the domain. For example, an `IssueType` enum in the `Domain.Shared` can be used by an `Issue` entity in the `Domain` project. +* `Application.Contracts` depends on the `Domain.Shared`. In this way, you can reuse these types in the DTOs. For example, the same `IssueType` enum in the `Domain.Shared` can be used by a `CreateIssueDto` as a property. +* `Application` depends on the `Application.Contracts` since it implements the Application Service interfaces and uses the DTOs inside it. It also depends on the `Domain` since the Application Services are implemented using the Domain Objects defined inside it. +* `EntityFrameworkCore` depends on the `Domain` since it maps the Domain Objects (entities and value types) to database tables (as it is an ORM) and implements the repository interfaces defined in the `Domain`. +* `HttpApi` depends on the `Application.Contacts` since the Controllers inside it inject and use the Application Service interfaces as explained before. +* `HttpApi.Client` depends on the `Application.Contacts` since it can consume the Application Services as explained before. +* `Web` depends on the `HttpApi` since it serves the HTTP APIs defined inside it. Also, in this way, it indirectly depends on the `Application.Contacts` project to consume the Application Services in the Pages/Components. + +#### Dashed Dependencies + +When you investigate the solution, you will see two more dependencies shown with the dashed lines in the figure above. `Web` project depends on the `Application` and `EntityFrameworkCore` projects which *theoretically* should not be like that but actually it is. + +This is because the `Web` is the final project that runs and hosts the application and the **application needs the implementations of the Application Services and the Repositories** while running. + +This design decision potentially allows you to use Entities and EF Core objects in the Presentation Layer which **should be strictly avoided**. However, we find the alternative designs over complicated. Here, two of the alternatives if you want to remove this dependency; + +* Convert `Web` project to a razor class library and create a new project, like `Web.Host`, that depends on the `Web`, `Application` and `EntityFrameworkCore` projects and hosts the application. You don't write any UI code here, but use **only for hosting**. +* Remove `Application` and `EntityFrameworkCore` dependencies from the `Web` project and load their assemblies on application initialization. You can use ABP's [Plug-In Modules](PlugIn-Modules.md) system for that purpose. + +### Execution Flow a DDD Based Application + +The figure below shows a typical request flow for a web application that has been developed based on DDD patterns. + +![](images/domain-driven-design-web-request-flow.png) + +* The request typically begins with a user interaction on the UI (a *use case*) that causes an HTTP request to the server. +* An MVC Controller or a Razor Page Handler in the Presentation Layer (or in the Distributed Services Layer) handles the request and can perform some cross cutting concerns in this stage ([Authorization](Authorization.md), [Validation](Validation.md), [Exception Handling](Exception-Handling.md), etc.). A Controller/Page injects the related Application Service interface and calls its method(s) by sending and receiving DTOs. +* The Application Service uses the Domain Objects (Entities, Repository interfaces, Domain Services, etc.) to implement the *use case*. Application Layer implements some cross cutting concerns (Authorization, Validation, etc.). An Application Service method should be a [Unit Of Work](Unit-Of-Work.md). That means it should be atomic. + +Most of the cross cutting concerns are **automatically and conventionally implemented by the ABP Framework** and you typically don't need to write code for them. + +### Common Principles + +Before going into details, let's see some overall DDD principles; + +#### Database Provider / ORM Independence + +The domain and the application layers should be ORM / Database Provider agnostic. They should only depend on the Repository interfaces and the Repository interfaces don't use any ORM specific objects. + +Here, the main reasons of this principle; + +1. To make your domain/application **infrastructure independent** since the infrastructure may change in the future or you may need to support a second database type later. +2. To make your domain/application **focus on the business code** by hiding the infrastructure details behind the repositories. +3. To make your **automated tests** easier since you can mock the repositories in this case. + +> As a respect to this principle, none of the projects in the solution has reference to the `EntityFrameworkCore` project, except the startup application. + +##### Discussion About the Database Independence Principle + +Especially, the **reason 1** deeply effects your domain **object design** (especially, the entity relations) and **application code**. Assume that you are using [Entity Framework Core](Entity-Framework-Core.md) with a relational database. If you are willing to make your application switchable to [MongoDB](MongoDB.md) later, you can't use some very **useful EF Core features**. Examples; + +* You can't assume [Change Tracking](https://docs.microsoft.com/en-us/ef/core/querying/tracking) since MongoDB provider can't do it. So, you always need to explicitly update the changed entities. +* You can't use [Navigation Properties](https://docs.microsoft.com/en-us/ef/core/modeling/relationships) (or Collections) to other Aggregates in your entities since this is not possible for a Document Database. See the "Rule: Reference Other Aggregates Only By Id" section for more info. + +If you think such features are **important** for you and you **will never stray** from the EF Core, we believe that it is worth **stretching this principle**. We still suggest to use the repository pattern to hide the infrastructure details. But you can assume that you are using EF Core while designing your entity relations and writing your application code. You can even reference to the EF Core NuGet Package from your application layer to be able to directly use the asynchronous LINQ extension methods, like `ToListAsync()` (see the *IQueryable & Async Operations* section in the [Repositories](Repositories.md) document for more info). + +#### Presentation Technology Agnostic + +The presentation technology (UI Framework) is one of the most changed parts of a real world application. It is very important to design the **Domain and Application Layers** to be completely **unaware** of the presentation technology/framework. This principle is relatively easy to implement and ABP's startup template makes it even easier. + +In some cases, you may need to have **duplicate logic** in the application and presentation layers. For example, you may need to duplicate the **validation** and **authorization** checks in both layers. The checks in the UI layer is mostly for **user experience** while checks in the application and domain layers are for **security and data integrity**. That's perfectly normal and necessary. + +#### Focus on the State Changes, Not Reporting + +DDD focuses on how the domain objects **changes and interactions**; How to create an entity and change its properties by preserving the data **integrity/validity** and implementing the **business rules**. + +DDD **ignores reporting** and mass querying. That doesn't mean they are not important. If your application doesn't have fancy dashboards and reports, who would use it? However, reporting is another topic. You typically want to use the full power of the SQL Server or even use a separate data source (like ElasticSearch) for reporting purpose. You will write optimized queries, create indexes and even stored procedures(!). You are free to do all these things as long as you don't infect them into your business logic. + +## Implementation: The Building Blocks + +This is the essential part of this guide. We will introduce and explain some **explicit rules** with examples. You can follow these rules and apply in your solution while implementing the Domain Driven Design. + +### The Example Domain + +The examples will use some concepts those are used by GitHub, like `Issue`, `Repository`, `Label` and `User`, you are already familiar with. The figure below shows some of the aggregates, aggregate roots, entities, value object and the relations between them: + +![domain driven design example schema](images/domain-driven-design-example-domain-schema.png) + +**Issue Aggregate** consists of an `Issue` Aggregate Root that contains `Comment` and `IssueLabel` collections. Other aggregates are shown as simple since we will focus on the Issue Aggregate: + +![domain-driven-design-issue-aggregate-diagram](images/domain-driven-design-issue-aggregate-diagram.png) + +### Aggregates + +As said before, an [Aggregate](Entities.md) is a cluster of objects (entities and value objects) bound together by an Aggregate Root object. This section will introduce the principles and rules related to the Aggregates. + +> We refer the term *Entity* both for *Aggregate Root* and *sub-collection entities* unless we explicitly write *Aggregate Root* or *sub-collection entity*. + +#### Aggregate / Aggregate Root Principles + +##### Business Rules + +Entities are responsible to implement the business rules related to the properties of their own. The *Aggregate Root Entities* are also responsible for their sub-collection entities. + +An aggregate should maintain its self **integrity** and **validity** by implementing domain rules and constraints. That means, unlike the DTOs, Entities have **methods to implement some business logic**. Actually, we should try to implement business rules in the entities wherever possible. + +##### Single Unit + +An aggregate is **retrieved and saved as a single unit**, with all the sub-collections and properties. For example, if you want to add a `Comment` to an `Issue`, you need to; + +* Get the `Issue` from database with including all the sub-collections (`Comment`s and `IssueLabel`s). +* Use methods on the `Issue` class to add a new comment, like `Issue.AddComment(...);`. +* Save the `Issue` (with all sub-collections) to the database as a single database operation (update). + +That may seem strange to the developers used to work with **EF Core & Relational Databases** before. Getting the `Issue` with all details seems **unnecessary and inefficient**. Why don't we just execute an SQL `Insert` command to database without querying any data? + +The answer is that we should **implement the business** rules and preserve the data **consistency** and **integrity** in the **code**. If we have a business rule like "*Users can not comment on the locked issues*", how can we check the `Issue`'s lock state without retrieving it from the database? So, we can execute the business rules only if the related objects available in the application code. + +On the other hand, **MongoDB** developers will find this rule very natural. In MongoDB, an aggregate object (with sub-collections) is saved in a **single collection** in the database (while it is distributed into several tables in a relational database). So, when you get an aggregate, all the sub-collections are already retrieved as a part of the query, without any additional configuration. + +ABP Framework helps to implement this principle in your applications. + +**Example: Add a comment to an issue** + +````csharp +public class IssueAppService : ApplicationService, IIssueAppService +{ + private readonly IRepository _issueRepository; + + public IssueAppService(IRepository issueRepository) + { + _issueRepository = issueRepository; + } + + [Authorize] + public async Task CreateCommentAsync(CreateCommentDto input) + { + var issue = await _issueRepository.GetAsync(input.IssueId); + issue.AddComment(CurrentUser.GetId(), input.Text); + await _issueRepository.UpdateAsync(issue); + } +} +```` + +`_issueRepository.GetAsync` method retrieves the `Issue` with all details (sub-collections) as a single unit by default. While this works out of the box for MongoDB, you need to configure your aggregate details for the EF Core. But, once you configure, repositories automatically handle it. `_issueRepository.GetAsync` method gets an optional parameter, `includeDetails`, that you can pass `false` to disable this behavior when you need it. + +> See the *Loading Related Entities* section of the [EF Core document](Entity-Framework-Core.md) for the configuration and alternative scenarios. + +`Issue.AddComment` gets a `userId` and comment `text`, implements the necessary business rules and adds the comment to the Comments collection of the `Issue`. + +Finally, we use `_issueRepository.UpdateAsync` to save changes to the database. + +> EF Core has a **change tracking** feature. So, you actually don't need to call `_issueRepository.UpdateAsync`. It will be automatically saved thanks to ABP's Unit Of Work system that automatically calls `DbContext.SaveChanges()` at the end of the method. However, for MongoDB, you need to explicitly update the changed entity. +> +> So, if you want to write your code Database Provider independent, you should always call the `UpdateAsync` method for the changed entities. + +##### Transaction Boundary + +An aggregate is generally considered as a transaction boundary. If a use case works with a single aggregate, reads and saves it as a single unit, all the changes made to the aggregate objects are saved together as an atomic operation and you don't need to an explicit database transaction. + +However, in real life, you may need to change **more than one aggregate instances** in a single use case and you need to use database transactions to ensure **atomic update** and **data consistency**. Because of that, ABP Framework uses an explicit database transaction for a use case (an application service method boundary). See the [Unit Of Work](Unit-Of-Work.md) documentation for more info. + +##### Serializability + +An aggregate (with the root entity and sub-collections) should be serializable and transferrable on the wire as a single unit. For example, MongoDB serializes the aggregate to JSON document while saving to the database and deserializes from JSON while reading from the database. + +> This requirement is not necessary when you use relational databases and ORMs. However, it is an important practice of Domain Driven Design. + +The following rules will already bring the serializability. + +#### Aggregate / Aggregate Root Rules & Best Practices + +The following rules ensures implementing the principles introduced above. + +##### Reference Other Aggregates Only By Id + +The first rule says an Aggregate should reference to other aggregates only by their Id. That means you can not add navigation properties to other aggregates. + +* This rule makes it possible to implement the serializability principle. +* It also prevents different aggregates manipulate each other and leaking business logic of an aggregate to one another. + +You see two aggregate roots, `GitRepository` and `Issue` in the example below; + +![domain-driven-design-reference-by-id-sample](images/domain-driven-design-reference-by-id-sample.png) + +* `GitRepository` should not have a collection of the `Issue`s since they are different aggregates. +* `Issue` should not have a navigation property for the related `GitRepository` since it is a different aggregate. +* `Issue` can have `RepositoryId` (as a `Guid`). + +So, when you have an `Issue` and need to have `GitRepository` related to this issue, you need to explicitly query it from database by the `RepositoryId`. + +###### For EF Core & Relational Databases + +In MongoDB, it is naturally not suitable to have such navigation properties/collections. If you do that, you find a copy of the destination aggregate object in the database collection of the source aggregate since it is being serialized to JSON on save. + +However, EF Core & relational database developers may find this restrictive rule unnecessary since EF Core can handle it on database read and write. We see this an important rule that helps to **reduce the complexity** of the domain prevents potential problems and we strongly suggest to implement this rule. However, if you think it is practical to ignore this rule, see the *Discussion About the Database Independence Principle* section above. + +##### Keep Aggregates Small + +One good practice is to keep an aggregate simple and small. This is because an aggregate will be loaded and saved as a single unit and reading/writing a big object has performance problems. See the example below: + +![domain-driven-design-aggregate-keep-small](images/domain-driven-design-aggregate-keep-small.png) + +Role aggregate has a collection of `UserRole` value objects to track the users assigned for this role. Notice that `UserRole` is not another aggregate and it is not a problem for the rule *Reference Other Aggregates Only By Id*. However, it is a problem in practical. A role may be assigned to thousands (even millions) of users in a real life scenario and it is a significant performance problem to load thousands of items whenever you query a `Role` from database (remember: Aggregates are loaded by their sub-collections as a single unit). + +On the other hand, `User` may have such a `Roles` collection since a user doesn't have much roles in practical and it can be useful to have a list of roles while you are working with a User Aggregate. + +If you think carefully, there is one more problem when Role and User both have the list of relation when use a **non-relational database, like MongoDB**. In this case, the same information is duplicated in different collections and it will be hard to maintain data consistency (whenever you add an item to `User.Roles`, you need to add it to `Role.Users` too). + +So, determine your aggregate boundaries and size based on the following considerations; + +* Objects used together. +* Query (load/save) performance and memory consumption. +* Data integrity, validity and consistency. + +In practical; + +* Most of the aggregate roots will **not have sub-collections**. +* A sub-collection should not have more than **100-150 items** inside it at the most case. If you think a collection potentially can have more items, don't define the collection as a part of the aggregate and consider to extract another aggregate root for the entity inside the collection. + +##### Primary Keys of the Aggregate Roots / Entities + +* An aggregate root typically has a single `Id` property for its identifier (Primark Key: PK). We prefer `Guid` as the PK of an aggregate root entity (see the [Guid Genertation document](Guid-Generation.md) to learn why). +* An entity (that's not the aggregate root) in an aggregate can use a composite primary key. + +For example, see the Aggregate root and the Entity below: + +![domain-driven-design-entity-primary-keys](images/domain-driven-design-entity-primary-keys.png) + +* `Organization` has a `Guid` identifier (`Id`). +* `OrganizationUser` is a sub-collection of an `Organization` and has a composite primary key consists of the `OrganizationId` and `UserId`. + +That doesn't mean sub-collection entities should always have composite PKs. They may have single `Id` properties when it's needed. + +> Composite PKs are actually a concept of relational databases since the sub-collection entities have their own tables and needs to a PK. On the other hand, for example, in MongoDB you don't need to define PK for the sub-collection entities at all since they are stored as a part of the aggregate root. + +##### Constructors of the Aggregate Roots / Entities + +The constructor is located where the lifecycle of an entity begins. There are a some responsibilities of a well designed constructor: + +* Gets the **required entity properties** as parameters to **create a valid entity**. Should force to pass only for the required parameters and may get non-required properties as optional parameters. +* **Checks validity** of the parameters. +* Initializes **sub-collections**. + +**Example: `Issue` (Aggregate Root) constructor** + +````csharp +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Volo.Abp; +using Volo.Abp.Domain.Entities; + +namespace IssueTracking.Issues +{ + public class Issue : AggregateRoot + { + public Guid RepositoryId { get; set; } + public string Title { get; set; } + public string Text { get; set; } + public Guid? AssignedUserId { get; set; } + public bool IsClosed { get; set; } + public IssueCloseReason? CloseReason { get; set; } //enum + + public ICollection Labels { get; set; } + + public Issue( + Guid id, + Guid repositoryId, + string title, + string text = null, + Guid? assignedUserId = null + ) : base(id) + { + RepositoryId = repositoryId; + Title = Check.NotNullOrWhiteSpace(title, nameof(title)); + + Text = text; + AssignedUserId = assignedUserId; + + Labels = new Collection(); + } + + private Issue() { /* for deserialization & ORMs */ } + } +} +```` + +* `Issue` class properly **forces to create a valid entity** by getting minimum required properties in its constructor as parameters. +* The constructor **validates** the inputs (`Check.NotNullOrWhiteSpace(...)` throws `ArgumentException` if the given value is empty). +* It **initializes the sub-collections**, so you don't get a null reference exception when you try to use the `Labels` collection after creating the `Issue`. +* The constructor also **takes the `id`** and passes to the `base` class. We don't generate `Guid`s inside the constructor to be able to delegate this responsibility to another service (see [Guid Generation](Guid-Generation.md)). +* Private **empty constructor** is necessary for ORMs. We made it `private` to prevent accidently using it in our own code. + +> See the [Entities](Entities.md) document to learn more about creating entities with the ABP Framework. + +##### Entity Property Accessors & Methods + +The example above may seem strange to you! For example, we force to pass a non-null `Title` in the constructor. However, the developer may then set the `Title` property to `null` without any control. This is because the example code above just focuses on the constructor. + +If we declare all the properties with **public setters** (like the example `Issue` class above), we can't force **validity** and **integrity** of the entity in its lifecycle. So; + +* Use **private setter** for a property when you need to perform any **logic** while setting that property. +* Define public methods to manipulate such properties. + +**Example: Methods to change the properties in a controlled way** + +````csharp +using System; +using Volo.Abp; +using Volo.Abp.Domain.Entities; + +namespace IssueTracking.Issues +{ + public class Issue : AggregateRoot + { + public Guid RepositoryId { get; private set; } //Never changes + public string Title { get; private set; } //Needs validation + public string Text { get; set; } //No validation + public Guid? AssignedUserId { get; set; } //No validation + public bool IsClosed { get; private set; } //Should be changed with CloseReason + public IssueCloseReason? CloseReason { get; private set; } //Should be changed with IsClosed + + //... + + public void SetTitle(string title) + { + Title = Check.NotNullOrWhiteSpace(title, nameof(title)); + } + + public void Close(IssueCloseReason reason) + { + IsClosed = true; + CloseReason = reason; + } + + public void ReOpen() + { + IsClosed = false; + CloseReason = null; + } + } +} +```` + +* `RepositoryId` setter made private and there is no way to change it after creating an `Issue` because this is what we want in this domain: An issue can't be moved to another repository. +* `Title` setter made private and `SetTitle` method has been created if you want to change it later in a controlled way. +* `Text` and `AssignedUserId` has public setters since there is no restriction on them. They can be null or any other value. We think it is unnecessary to define separate methods to set them. If we need later, we can add methods and make the setters private. Breaking changes are not problem in the domain layer since the domain layer is an internal project, it is not exposed to clients. +* `IsClosed` and `IssueCloseReason` are pair properties. Defined `Close` and `ReOpen` methods to change them together. In this way, we prevent to close an issue without any reason. + +##### Business Logic & Exceptions in the Entities + +When you implement validation and business logic in the entities, you frequently need to manage the exceptional cases. In these cases; + +* Create **domain specific exceptions**. +* **Throw these exceptions** in the entity methods when necessary. + +**Example** + +````csharp +public class Issue : AggregateRoot +{ + //... + + public bool IsLocked { get; private set; } + public bool IsClosed { get; private set; } + public IssueCloseReason? CloseReason { get; private set; } + + public void Close(IssueCloseReason reason) + { + IsClosed = true; + CloseReason = reason; + } + + public void ReOpen() + { + if (IsLocked) + { + throw new IssueStateException( + "Can not open a locked issue! Unlock it first." + ); + } + + IsClosed = false; + CloseReason = null; + } + + public void Lock() + { + if (!IsClosed) + { + throw new IssueStateException( + "Can not open a locked issue! Unlock it first." + ); + } + + IsLocked = true; + } + + public void Unlock() + { + IsLocked = false; + } +} +```` + +There are two business rules here; + +* A locked issue can not be re-opened. +* You can not lock an open issue. + +`Issue` class throws an `IssueStateException` in these cases to force the business rules: + +````csharp +using System; + +namespace IssueTracking.Issues +{ + public class IssueStateException : Exception + { + public IssueStateException(string message) + : base(message) + { + + } + } +} +```` + +There are two potential problems of throwing such exceptions; + +1. In case of such an exception, should the **end user** see the exception (error) message? If so, how do you **localize** the exception message? You can not use the [localization](Localization.md) system, because you can't inject and use `IStringLocalizer` in the entities. +2. For a web application or HTTP API, what **HTTP Status Code** should return to the client? + +ABP's [Exception Handling](Exception-Handling.md) system solves these and similar problems. + +**Example: Throwing a business exception with code** + +````csharp +using Volo.Abp; + +namespace IssueTracking.Issues +{ + public class IssueStateException : BusinessException + { + public IssueStateException(string code) + : base(code) + { + + } + } +} +```` + +* `IssueStateException` class inherits the `BusinessException` class. ABP returns 403 (forbidden) HTTP Status code by default (instead of 500 - Internal Server Error) for the exceptions derived from the `BusinessException`. +* The `code` is used as a key in the localization resource file to find the localized message. + +Now, we can change the `ReOpen` method as shown below: + +````csharp +public void ReOpen() +{ + if (IsLocked) + { + throw new IssueStateException("IssueTracking:CanNotOpenLockedIssue"); + } + + IsClosed = false; + CloseReason = null; +} +```` + +> Use constants instead of magic strings. + +And add an entry to the localization resource like below: + +````json +"IssueTracking:CanNotOpenLockedIssue": "Can not open a locked issue! Unlock it first." +```` + +* When you throw the exception, ABP automatically uses this localized message (based on the current language) to show to the end user. +* The exception code (`IssueTracking:CanNotOpenLockedIssue` here) is also sent to the client, so it may handle the error case programmatically. + +> For this example, you could directly throw `BusinessException` instead of defining a specialized `IssueStateException`. The result will be same. See the [exception handling document](Exception-Handling.md) for all the details. + +##### Business Logic in Entities Requiring External Services + +It is simple to implement a business rule in an entity method when the business logic only uses the properties of that entity. What if the business logic requires to **query database** or **use any external services** that should be resolved from the [dependency injection](Dependency-Injection.md) system. Remember; **Entities can not inject services!** + +There are two common ways of implementing such a business logic: + +* Implement the business logic on an entity method and **get external dependencies as parameters** of the method. +* Create a **Domain Service**. + +Domain Services will be explained later. But, now let's see how it can be implemented in the entity class. + +**Example: Business Rule: Can not assign more than 3 open issues to a user concurrently** + +````csharp +public class Issue : AggregateRoot +{ + //... + public Guid? AssignedUserId { get; private set; } + + public async Task AssignToAsync(AppUser user, IUserIssueService userIssueService) + { + var openIssueCount = await userIssueService.GetOpenIssueCountAsync(user.Id); + + if (openIssueCount >= 3) + { + throw new BusinessException("IssueTracking:ConcurrentOpenIssueLimit"); + } + + AssignedUserId = user.Id; + } + + public void CleanAssignment() + { + AssignedUserId = null; + } +} +```` + +* `AssignedUserId` property setter made private. So, the only way to change it to use the `AssignToAsync` and `CleanAssignment` methods. +* `AssignToAsync` gets an `AppUser` entity. Actually, it only uses the `user.Id`, so you could get a `Guid` value, like `userId`. However, this way ensures that the `Guid` value is `Id` of an existing user and not a random `Guid` value. +* `IUserIssueService` is an arbitrary service that is used to get open issue count for a user. It's the responsibility of the code part (that calls the `AssignToAsync`) to resolve the `IUserIssueService` and pass here. +* `AssignToAsync` throws exception if the business rule doesn't meet. +* Finally, if everything is correct, `AssignedUserId` property is set. + +This method perfectly guarantees to apply the business logic when you want to assign an issue to a user. However, it has some problems; + +* It makes the entity class **depending on an external service** which makes the entity **complicated**. +* It makes **hard to use** the entity. The code that uses the entity now needs to inject `IUserIssueService` and pass to the `AssignToAsync` method. + +An alternative way of implementing this business logic is to introduce a **Domain Service**, which will be explained later. + +### Repositories + +A [Repository](Repositories.md) is a collection-like interface that is used by the Domain and Application Layers to access to the data persistence system (the database) to read and write the Business Objects, generally the Aggregates. + +Common Repository principles are; + +* Define a repository **interface in the Domain Layer** (because it is used in the Domain and Application Layers), **implement in the Infrastructure Layer** (*EntityFrameworkCore* project in the startup template). +* **Do not include business logic** inside the repositories. +* Repository interface should be **database provider / ORM independent**. For example, do not return a `DbSet` from a repository method. `DbSet` is an object provided by the EF Core. +* **Create repositories for aggregate roots**, not for all entities. Because, sub-collection entities (of an aggregate) should be accessed over the aggregate root. + +#### Do Not Include Domain Logic in Repositories + +While this rule seems obvious at the beginning, it is easy to leak business logic into repositories. + +**Example: Get inactive issues from a repository** + +````csharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace IssueTracking.Issues +{ + public interface IIssueRepository : IRepository + { + Task> GetInActiveIssuesAsync(); + } +} +```` + +`IIssueRepository` extends the standard `IRepository<...>` interface by adding a `GetInActiveIssuesAsync` method. This repository works with such an `Issue` class: + +````csharp +public class Issue : AggregateRoot, IHasCreationTime +{ + public bool IsClosed { get; private set; } + public Guid? AssignedUserId { get; private set; } + public DateTime CreationTime { get; private set; } + public DateTime? LastCommentTime { get; private set; } + //... +} +```` + +(the code shows only the properties we need for this example) + +The rule says the repository shouldn't know the business rules. The question here is "**What is an inactive issue**? Is it a business rule definition?" + +Let's see the implementation to understand it: + +````csharp +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using IssueTracking.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace IssueTracking.Issues +{ + public class EfCoreIssueRepository : + EfCoreRepository, + IIssueRepository + { + public EfCoreIssueRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async Task> GetInActiveIssuesAsync() + { + var daysAgo30 = DateTime.Now.Subtract(TimeSpan.FromDays(30)); + + return await DbSet.Where(i => + + //Open + !i.IsClosed && + + //Assigned to nobody + i.AssignedUserId == null && + + //Created 30+ days ago + i.CreationTime < daysAgo30 && + + //No comment or the last comment was 30+ days ago + (i.LastCommentTime == null || i.LastCommentTime < daysAgo30) + + ).ToListAsync(); + } + } +} +```` + +(Used EF Core for the implementation. See the [EF Core integration document](Entity-Framework-Core.md) to learn how to create custom repositories with the EF Core.) + +When we check the `GetInActiveIssuesAsync` implementation, we see a **business rule that defines an in-active issue**: The issue should be **open**, **assigned to nobody**, **created 30+ days ago** and has **no comment in the last 30 days**. + +This is an implicit definition of a business rule that is hidden inside a repository method. The problem occurs when we need to reuse this business logic. + +For example, let's say that we want to add an `bool IsInActive()` method on the `Issue` entity. In this way, we can check activeness when we have an issue entity. + +Let's see the implementation: + +````csharp +public class Issue : AggregateRoot, IHasCreationTime +{ + public bool IsClosed { get; private set; } + public Guid? AssignedUserId { get; private set; } + public DateTime CreationTime { get; private set; } + public DateTime? LastCommentTime { get; private set; } + //... + + public bool IsInActive() + { + var daysAgo30 = DateTime.Now.Subtract(TimeSpan.FromDays(30)); + return + //Open + !IsClosed && + + //Assigned to nobody + AssignedUserId == null && + + //Created 30+ days ago + CreationTime < daysAgo30 && + + //No comment or the last comment was 30+ days ago + (LastCommentTime == null || LastCommentTime < daysAgo30); + } +} +```` + +We had to copy/paste/modify the code. What if the definition of the activeness changes? We should not forget to update both places. This is a duplication of a business logic, which is pretty dangerous. + +A good solution to this problem is the *Specification Pattern*! + +### Specifications + +A [specification](Specifications.md) is a **named**, **reusable**, **combinable** and **testable** class to filter the Domain Objects based on the business rules. + +ABP Framework provides necessary infrastructure to easily create specification classes and use them inside your application code. Let's implement the in-active issue filter as a specification class: + +````csharp +using System; +using System.Linq.Expressions; +using Volo.Abp.Specifications; + +namespace IssueTracking.Issues +{ + public class InActiveIssueSpecification : Specification + { + public override Expression> ToExpression() + { + var daysAgo30 = DateTime.Now.Subtract(TimeSpan.FromDays(30)); + return i => + + //Open + !i.IsClosed && + + //Assigned to nobody + i.AssignedUserId == null && + + //Created 30+ days ago + i.CreationTime < daysAgo30 && + + //No comment or the last comment was 30+ days ago + (i.LastCommentTime == null || i.LastCommentTime < daysAgo30); + } + } +} +```` + +`Specification` base class simplifies to create a specification class by defining an expression. Just moved the expression here, from the repository. + +Now, we can re-use the `InActiveIssueSpecification` in the `Issue` entity and `EfCoreIssueRepository` classes. + +#### Using within the Entity + +`Specification` class provides an `IsSatisfiedBy` method that returns `true` if the given object (entity) satisfies the specification. We can re-write the `Issue.IsInActive` method as shown below: + +````csharp +public class Issue : AggregateRoot, IHasCreationTime +{ + public bool IsClosed { get; private set; } + public Guid? AssignedUserId { get; private set; } + public DateTime CreationTime { get; private set; } + public DateTime? LastCommentTime { get; private set; } + //... + + public bool IsInActive() + { + return new InActiveIssueSpecification().IsSatisfiedBy(this); + } +} +```` + +Just created a new instance of the `InActiveIssueSpecification` and used its `IsSatisfiedBy` method to re-use the expression defined by the specification. + +#### Using with the Repositories + +First, starting from the repository interface: + +````csharp +public interface IIssueRepository : IRepository +{ + Task> GetIssuesAsync(ISpecification spec); +} +```` + +Renamed `GetInActiveIssuesAsync` to simple `GetIssuesAsync` by taking a specification object. Since the **specification (the filter) has been moved out of the repository**, we no longer need to create different methods to get issues with different conditions (like `GetAssignedIssues(...)`, `GetLockedIssues(...)`, etc.) + +Updated implementation of the repository can be like that: + +````csharp +public class EfCoreIssueRepository : + EfCoreRepository, + IIssueRepository +{ + public EfCoreIssueRepository( + IDbContextProvider dbContextProvider) + : base(dbContextProvider) + { + } + + public async Task> GetIssuesAsync(ISpecification spec) + { + return await DbSet + .Where(spec.ToExpression()) + .ToListAsync(); + } +} +```` + +Since `ToExpression()` method returns an expression, it can be directly passed to the `Where` method to filter the entities. + +Finally, we can pass any Specification instance to the `GetIssuesAsync` method: + +````csharp +public class IssueAppService : ApplicationService, IIssueAppService +{ + private readonly IIssueRepository _issueRepository; + + public IssueAppService(IIssueRepository issueRepository) + { + _issueRepository = issueRepository; + } + + public async Task DoItAsync() + { + var issues = await _issueRepository.GetIssuesAsync( + new InActiveIssueSpecification() + ); + } +} +```` + +##### With Default Repositories + +Actually, you don't have to create custom repositories to be able to use specifications. The standard `IRepository` already extends the `IQueryable`, so you can use the standard LINQ extension methods over it: + +````csharp +public class IssueAppService : ApplicationService, IIssueAppService +{ + private readonly IRepository _issueRepository; + + public IssueAppService(IRepository issueRepository) + { + _issueRepository = issueRepository; + } + + public async Task DoItAsync() + { + var issues = AsyncExecuter.ToListAsync( + _issueRepository.Where(new InActiveIssueSpecification()) + ); + } +} +```` + +`AsyncExecuter` is a utility provided by the ABP Framework to use asynchronous LINQ extension methods (like `ToListAsync` here) without depending on the EF Core NuGet package. See the [Repositories document](Repositories.md) for more information. + +#### Combining the Specifications + +One powerful side of the Specifications is they are combinable. Assume that we have another specification that returns `true` only if the `Issue` is in a Milestone: + +````csharp +public class MilestoneSpecification : Specification +{ + public Guid MilestoneId { get; } + + public MilestoneSpecification(Guid milestoneId) + { + MilestoneId = milestoneId; + } + + public override Expression> ToExpression() + { + return i => i.MilestoneId == MilestoneId; + } +} +```` + +This Specification is *parametric* as a difference from the `InActiveIssueSpecification`. We can combine both specifications to get a list of inactive issues in a specific milestone: + +````csharp +public class IssueAppService : ApplicationService, IIssueAppService +{ + private readonly IRepository _issueRepository; + + public IssueAppService(IRepository issueRepository) + { + _issueRepository = issueRepository; + } + + public async Task DoItAsync(Guid milestoneId) + { + var issues = AsyncExecuter.ToListAsync( + _issueRepository + .Where( + new InActiveIssueSpecification() + .And(new MilestoneSpecification(milestoneId)) + .ToExpression() + ) + ); + } +} +```` + +The example above uses the `And` extension method to combine the specifications. There are more combining methods are available, like `Or(...)` and `AndNot(...)`. + +> See the [Specifications document](Specifications.md) for more details about the specification infrastructure provided by the ABP Framework. + +### Domain Services + +Domain Services implement domain logic which; + +* Depends on **services and repositories**. +* Needs to work with **multiple aggregates**, so the logic doesn't properly fit in any of the aggregates. + +Domain Services work with Domain Objects. Their methods can **get and return entities, value objects, primitive types**... etc. However, **they don't get/return DTOs**. DTOs is a part of the Application Layer. + +**Example: Assigning an issue to a user** + +Remember how an issue assignment has been implemented in the `Issue` entity: + +````csharp +public class Issue : AggregateRoot +{ + //... + public Guid? AssignedUserId { get; private set; } + + public async Task AssignToAsync(AppUser user, IUserIssueService userIssueService) + { + var openIssueCount = await userIssueService.GetOpenIssueCountAsync(user.Id); + + if (openIssueCount >= 3) + { + throw new BusinessException("IssueTracking:ConcurrentOpenIssueLimit"); + } + + AssignedUserId = user.Id; + } + + public void CleanAssignment() + { + AssignedUserId = null; + } +} +```` + +Here, we will move this logic into a Domain Service. + +First, changing the `Issue` class: + +````csharp +public class Issue : AggregateRoot +{ + //... + public Guid? AssignedUserId { get; internal set; } +} +```` + +* Removed the assign-related methods. +* Changed `AssignedUserId` property's setter from `private` to `internal`, to allow to set it from the Domain Service. + +The next step is to create a domain service, named `IssueManager`, that has `AssignToAsync` to assign the given issue to the given user. + +````csharp +public class IssueManager : DomainService +{ + private readonly IRepository _issueRepository; + + public IssueManager(IRepository issueRepository) + { + _issueRepository = issueRepository; + } + + public async Task AssignToAsync(Issue issue, AppUser user) + { + var openIssueCount = await _issueRepository.CountAsync( + i => i.AssignedUserId == user.Id && !i.IsClosed + ); + + if (openIssueCount >= 3) + { + throw new BusinessException("IssueTracking:ConcurrentOpenIssueLimit"); + } + + issue.AssignedUserId = user.Id; + } +} +```` + +`IssueManager` can inject any service dependency and use to query open issue count on the user. + +> We prefer and suggest to use the `Manager` suffix for the Domain Services. + +The only problem of this design is that `Issue.AssignedUserId` is now open to set out of the class. However, it is not `public`. It is `internal` and changing it is possible only inside the same Assembly, the `IssueTracking.Domain` project for this example solution. We think this is reasonable; + +* Domain Layer developers are already aware of domain rules and they use the `IssueManager`. +* Application Layer developers are already forces to use the `IssueManager` since they don't directly set it. + +While there is a tradeoff between two approaches, we prefer to create Domain Services when the business logic requires to work with external services. + +> If you don't have a good reason, we think **there is no need to create interfaces** (like `IIssueManager` for the `IssueManager`) for Domain Services. + +### Application Services + +An [Application Service](Application-Services.md) is a stateless service that implements **use cases** of the application. An application service typically **gets and returns DTOs**. It is used by the Presentation Layer. It **uses and coordinates the domain objects** (entities, repositories, etc.) to implement the use cases. + +Common principles of an application service are; + +* Implement the **application logic** that is specific to the current use-case. Do not implement the core domain logic inside the application services. We will come back to differences between Application Domain logics. +* **Never get or return entities** for an application service method. This breaks the encapsulation of the Domain Layer. Always get and return DTOs. + +**Example: Assign an Issue to a User** + +````csharp +using System; +using System.Threading.Tasks; +using IssueTracking.Users; +using Microsoft.AspNetCore.Authorization; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; + +namespace IssueTracking.Issues +{ + public class IssueAppService : ApplicationService, IIssueAppService + { + private readonly IssueManager _issueManager; + private readonly IRepository _issueRepository; + private readonly IRepository _userRepository; + + public IssueAppService( + IssueManager issueManager, + IRepository issueRepository, + IRepository userRepository) + { + _issueManager = issueManager; + _issueRepository = issueRepository; + _userRepository = userRepository; + } + + [Authorize] + public async Task AssignAsync(IssueAssignDto input) + { + var issue = await _issueRepository.GetAsync(input.IssueId); + var user = await _userRepository.GetAsync(input.UserId); + + await _issueManager.AssignToAsync(issue, user); + + await _issueRepository.UpdateAsync(issue); + } + } +} +```` + +An application service method typically has three steps those are implemented here; + +1. Get the related domain objects from database to implement the use case. +2. Use domain objects (domain services, entities, etc.) to perform the actual operation. +3. Update the changed entities in the database. + +> The last *Update* is not necessary if your are using EF Core since it has a Change Tracking system. If you want to take advantage of this EF Core feature, please see the *Discussion About the Database Independence Principle* section above. + +`IssueAssignDto` in this example is a simple DTO class: + +````csharp +using System; + +namespace IssueTracking.Issues +{ + public class IssueAssignDto + { + public Guid IssueId { get; set; } + public Guid UserId { get; set; } + } +} +```` + +### Data Transfer Objects + +A [DTO](Data-Transfer-Objects.md) is a simple object that is used to transfer state (data) between the Application and Presentation Layers. So, Application Service methods gets and returns DTOs. + +#### Common DTO Principles & Best Practices + +* A DTO **should be serializable**, by its nature. Because, most of the time it is transferred over network. So, it should have a **parameterless (empty) constructor**. +* Should not contain any **business logic**. +* **Never** inherit from or reference to **entities**. + +**Input DTOs** (those are passed to the Application Service methods) have different natures than **Output DTOs** (those are returned from the Application Service methods). So, they will be treated differently. + +#### Input DTO Best Practices + +##### Do not Define Unused Properties for Input DTOs + +Define **only the properties needed** for the use case! Otherwise, it will be **confusing for the clients** to use the Application Service method. You can surely define **optional properties**, but they should effect how the use case is working, when the client provides them. + +This rule seems unnecessary first. Who would define unused parameters (input DTO properties) for a method? But it happens, especially when you try to reuse input DTOs. + +##### Do not Re-Use Input DTOs + +Define a **specialized input DTO for each use case** (Application Service method). Otherwise, some properties are not used in some cases and this violates the rule defined above: *Do not Define Unused Properties for Input DTOs*. + +Sometimes, it seems appealing to reuse the same DTO class for two use cases, because they are almost same. Even if they are same now, they will probably become different by the time and you will come to the same problem. **Code duplication is a better practice than coupling use cases**. + +Another way of reusing input DTOs is **inheriting** DTOs from each other. While this can be useful in some rare cases, most of the time it brings you to the same point. + +**Example: User Application Service** + +````csharp +public interface IUserAppService : IApplicationService +{ + Task CreateAsync(UserDto input); + Task UpdateAsync(UserDto input); + Task ChangePasswordAsync(UserDto input); +} +```` + +`IUserAppService` uses `UserDto` as the input DTO in all methods (use cases). `UserDto` is defined below: + +````csharp +public class UserDto +{ + public Guid Id { get; set; } + public string UserName { get; set; } + public string Email { get; set; } + public string Password { get; set; } + public DateTime CreationTime { get; set; } +} +```` + +For this example; + +* `Id` is not used in *Create* since the server determines it. +* `Password` is not used in *Update* since we have another method for it. +* `CreationTime` is never used since we can't allow client to send the Creation Time. It should be set in the server. + +A true implementation can be like that: + +````csharp +public interface IUserAppService : IApplicationService +{ + Task CreateAsync(UserCreationDto input); + Task UpdateAsync(UserUpdateDto input); + Task ChangePasswordAsync(UserChangePasswordDto input); +} +```` + +With the given input DTO classes: + +````csharp +public class UserCreationDto +{ + public string UserName { get; set; } + public string Email { get; set; } + public string Password { get; set; } +} + +public class UserUpdateDto +{ + public Guid Id { get; set; } + public string UserName { get; set; } + public string Email { get; set; } +} + +public class UserChangePasswordDto +{ + public Guid Id { get; set; } + public string Password { get; set; } +} +```` + +This is more maintainable approach although more code is written. + +**Exceptional Case**: There can be some exceptions for this rule: If you always want to develop two methods **in parallel**, they may share the same input DTO (by inheritance or direct reuse). For example, if you have a reporting page that has some filters and you have multiple Application Service methods (like screen report, excel report and csv report methods) use the same filters but returns different results, you may want to reuse the same filter input DTO to **couple these use cases**. Because, in this example, whenever you change a filter, you have to make the necessary changes in all the methods to have a consistent reporting system. + +##### Input DTO Validation Logic + +* Implement only **formal validation** inside the DTO. Use Data Annotation Validation Attributes or implement `IValidatableObject` for formal validation. +* **Do not perform domain validation**. For example, don't try to check unique username constraint in the DTOs. + +**Example: Using Data Annotation Attributes** + +````csharp +using System.ComponentModel.DataAnnotations; + +namespace IssueTracking.Users +{ + public class UserCreationDto + { + [Required] + [StringLength(UserConsts.MaxUserNameLength)] + public string UserName { get; set; } + + [Required] + [EmailAddress] + [StringLength(UserConsts.MaxEmailLength)] + public string Email { get; set; } + + [Required] + [StringLength(UserConsts.MaxEmailLength, + MinimumLength = UserConsts.MinPasswordLength)] + public string Password { get; set; } + } +} +```` + +ABP Framework automatically validates input DTOs, throws `AbpValidationException` and returns HTTP Status `400` to the client in case of an invalid input. + +> Some developers think it is better to separate the validation rules and DTO classes. We think the declarative (Data Annotation) approach is practical and useful and doesn't cause any design problem. However, ABP also supports [FluentValidation integration](FluentValidation.md) if you prefer the other approach. + +> See the [Validation document](Validation.md) for all validation options. + +#### Output DTO Best Practices + +* Keep output **DTO count minimum**. **Reuse** where possible (exception: Do not reuse input DTOs as output DTOs). +* Output DTOs can contain **more properties** than used in the client code. +* Return entity DTO from **Create** and **Update** methods. + +The main goals of these suggestions are; + +* Make client code easy to develop and extend; + * Dealing with **similar, but not same** DTOs are problematic on the client side. + * It is common to **need to other properties** on the UI/client in the future. Returning all properties (by considering security and privileges) of an entity makes client code easy to improve without requiring to touch to the backend code. + * If you are opening your API to **3rd-party clients** that you don't know requirements of each client. +* Make the server side code easy to develop and extend; + * You have less class to **understand and maintain**. + * You can reuse the Entity->DTO **object mapping** code. + * Returning same types from different methods make it easy and clear to create **new methods**. + +**Example: Returning Different DTO types from different methods** + +````csharp +public interface IUserAppService : IApplicationService +{ + UserDto Get(Guid id); + List GetUserNameAndEmail(Guid id); + List GetRoles(Guid id); + List GetList(); + UserCreateResultDto Create(UserCreationDto input); + UserUpdateResultDto Update(UserUpdateDto input); +} +```` + +*(We didn't use async methods to make the example cleaner, but use async in your real world application!)* + +The example code above returns different DTO types for each method. As you can guess, there will be a lot of code duplications for querying data, mapping entities to DTOs. + +The `IUserAppService` service above can be simplified: + +````csharp +public interface IUserAppService : IApplicationService +{ + UserDto Get(Guid id); + List GetList(); + UserDto Create(UserCreationDto input); + UserDto Update(UserUpdateDto input); +} +```` + +With a single output DTO: + +````csharp +public class UserDto +{ + public Guid Id { get; set; } + public string UserName { get; set; } + public string Email { get; set; } + public DateTime CreationTime { get; set; } + public List Roles { get; set; } +} +```` + +* Removed `GetUserNameAndEmail` and `GetRoles` since `Get` method already returns the necessary information. +* `GetList` now returns the same with `Get`. +* `Create` and `Update` also returns the same `UserDto`. + +Using the same DTO has a lot of advantages as explained before. For example, think a scenario where you show a **data grid** of Users on the UI. After updating a user, you can get the return value and **update it on the UI**. So, you don't need to call `GetList` again. This is why we suggest to return the entity DTO (`UserDto` here) as return value from the `Create` and `Update` operations. + +##### Discussion + +Some of the output DTO suggestions may not fit in every scenario. These suggestions can be ignored for **performance** reasons, especially when **large data sets** returned or when you create services for your own UI and you have **too many concurrent requests**. + +In these cases, you may want to create **specialized output DTOs with minimal information**. The suggestions above are especially for applications where **maintaining the codebase** is more important than **negligible performance lost**. + +#### Object to Object Mapping + +Automatic [object to object mapping](Object-To-Object-Mapping.md) is a useful approach to copy values from one object to another when two objects have same or similar properties. + +DTO and Entity classes generally have same/similar properties and you typically need to create DTO objects from Entities. ABP's [object to object mapping system](Object-To-Object-Mapping.md) with [AutoMapper](http://automapper.org/) integration makes these operations much easier comparing to manual mapping. + +* **Use** auto object mapping only for **Entity to output DTO** mappings. +* **Do not use** auto object mapping for **input DTO to Entity** mappings. + +There are some reasons why you **should not use** input DTO to Entity auto mapping; + +1. An Entity class typically has a **constructor** that takes parameters and ensures valid object creation. Auto object mapping operation generally requires an empty constructor. +2. Most of the entity properties will have **private setters** and you should use methods to change these properties in a controlled way. +3. You typically need to **carefully validate and process** the user/client input rather than blindly mapping to the entity properties. + +While some of these problems can be solved through mapping configurations (For example, AutoMapper allows to define custom mapping rules), it makes your business code **implicit/hidden** and **tightly coupled** to the infrastructure. We think the business code should be explicit, clear and easy to understand. + +See the *Entity Creation* section below for an example implementation of the suggestions made in this section. + +## Example Use Cases + +This section will demonstrate some example use cases and discuss alternative scenarios. + +### Entity Creation + +Creating an object from an Entity / Aggregate Root class is the first step of the lifecycle of that entity. The *Aggregate / Aggregate Root Rules & Best Practices* section suggests to **create a primary constructor** for the Entity class that guarantees to **create a valid entity**. So, whenever we need to create an instance of that entity, we should always **use that constructor**. + +See the `Issue` Aggregate Root class below: + +````csharp +public class Issue : AggregateRoot +{ + public Guid RepositoryId { get; private set; } + public string Title { get; private set; } + public string Text { get; set; } + public Guid? AssignedUserId { get; internal set; } + + public Issue( + Guid id, + Guid repositoryId, + string title, + string text = null + ) : base(id) + { + RepositoryId = repositoryId; + Title = Check.NotNullOrWhiteSpace(title, nameof(title)); + Text = text; //Allow empty/null + } + + private Issue() { /* Empty constructor is for ORMs */ } + + public void SetTitle(string title) + { + Title = Check.NotNullOrWhiteSpace(title, nameof(title)); + } + + //... +} +```` + +* This class guarantees to create a valid entity by its constructor. +* If you need to change the `Title` later, you need to use the `SetTitle` method which continues to keep `Title` in a valid state. +* If you want to assign this issue to a user, you need to use `IssueManager` (it implements some business rules before the assignment - see the *Domain Services* section above to remember). +* The `Text` property has a public setter, because it also accepts null values and does not have any validation rules for this example. It is also optional in the constructor. + +Let's see an Application Service method that is used to create an issue: + +````csharp +public class IssueAppService : ApplicationService, IIssueAppService +{ + private readonly IssueManager _issueManager; + private readonly IRepository _issueRepository; + private readonly IRepository _userRepository; + + public IssueAppService( + IssueManager issueManager, + IRepository issueRepository, + IRepository userRepository) + { + _issueManager = issueManager; + _issueRepository = issueRepository; + _userRepository = userRepository; + } + + public async Task CreateAsync(IssueCreationDto input) + { + // Create a valid entity + var issue = new Issue( + GuidGenerator.Create(), + input.RepositoryId, + input.Title, + input.Text + ); + + // Apply additional domain actions + if (input.AssignedUserId.HasValue) + { + var user = await _userRepository.GetAsync(input.AssignedUserId.Value); + await _issueManager.AssignToAsync(issue, user); + } + + // Save + await _issueRepository.InsertAsync(issue); + + // Return a DTO represents the new Issue + return ObjectMapper.Map(issue); + } +} +```` + +`CreateAsync` method; + +* Uses the `Issue` **constructor** to create a valid issue. It passes the `Id` using the [IGuidGenerator](Guid-Generation.md) service. It doesn't use auto object mapping here. +* If the client wants to **assign this issue to a user** on object creation, it uses the `IssueManager` to do it by allowing the `IssueManager` to perform the necessary checks before this assignment. +* **Saves** the entity to the database. +* Finally uses the `IObjectMapper` to return an `IssueDto` that is automatically created by **mapping** from the new `Issue` entity. + +#### Applying Domain Rules on Entity Creation + +The example `Issue` entity has no business rule on entity creation, except some formal validations in the constructor. However, there maybe scenarios where entity creation should check some extra business rules. + +For example, assume that you **don't want** to allow to create an issue if there is already an issue with **exactly the same `Title`**. Where to implement this rule? It is **not proper** to implement this rule in the **Application Service**, because it is a **core business (domain) rule** that should always be checked. + +This rule should be implemented in a **Domain Service**, `IssueManager` in this case. So, we need to force the Application Layer always to use the `IssueManager` to create a new `Issue.` + +First, we can make the `Issue` constructor `internal`, instead of `public`: + +````csharp +public class Issue : AggregateRoot +{ + //... + + internal Issue( + Guid id, + Guid repositoryId, + string title, + string text = null + ) : base(id) + { + RepositoryId = repositoryId; + Title = Check.NotNullOrWhiteSpace(title, nameof(title)); + Text = text; //Allow empty/null + } + + //... +} +```` + +This prevents Application Services to directly use the constructor, so they will use the `IssueManager`. Then we can add a `CreateAsync` method to the `IssueManager`: + +````csharp +using System; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Domain.Services; + +namespace IssueTracking.Issues +{ + public class IssueManager : DomainService + { + private readonly IRepository _issueRepository; + + public IssueManager(IRepository issueRepository) + { + _issueRepository = issueRepository; + } + + public async Task CreateAsync( + Guid repositoryId, + string title, + string text = null) + { + if (await _issueRepository.AnyAsync(i => i.Title == title)) + { + throw new BusinessException("IssueTracking:IssueWithSameTitleExists"); + } + + return new Issue( + GuidGenerator.Create(), + repositoryId, + title, + text + ); + } + } +} +```` + +* `CreateAsync` method checks if there is already an issue with the same title and throws a business exception in this case. +* If there is no duplication, it creates and returns a new `Issue`. + +The `IssueAppService` is changed as shown below in order to use the `IssueManager`'s `CreateAsync` method: + +````csharp +public class IssueAppService : ApplicationService, IIssueAppService +{ + private readonly IssueManager _issueManager; + private readonly IRepository _issueRepository; + private readonly IRepository _userRepository; + + public IssueAppService( + IssueManager issueManager, + IRepository issueRepository, + IRepository userRepository) + { + _issueManager = issueManager; + _issueRepository = issueRepository; + _userRepository = userRepository; + } + + public async Task CreateAsync(IssueCreationDto input) + { + // Create a valid entity using the IssueManager + var issue = await _issueManager.CreateAsync( + input.RepositoryId, + input.Title, + input.Text + ); + + // Apply additional domain actions + if (input.AssignedUserId.HasValue) + { + var user = await _userRepository.GetAsync(input.AssignedUserId.Value); + await _issueManager.AssignToAsync(issue, user); + } + + // Save + await _issueRepository.InsertAsync(issue); + + // Return a DTO represents the new Issue + return ObjectMapper.Map(issue); + } +} + +// *** IssueCreationDto class *** +public class IssueCreationDto +{ + public Guid RepositoryId { get; set; } + [Required] + public string Title { get; set; } + public Guid? AssignedUserId { get; set; } + public string Text { get; set; } +} +```` + +##### Discussion: Why is the Issue not saved to the database in `IssueManager`? + +You may ask "**Why didn't `IssueManager` save the `Issue` to the database?**". We think it is the responsibility of the Application Service. + +Because, the Application Service may require additional changes/operations on the `Issue` object before saving it. If Domain Service saves it, then the *Save* operation is duplicated; + +* It causes performance lost because of double database round trip. +* It requires explicit database transaction that covers both operations. +* If additional actions cancel the entity creation because of a business rule, the transaction should be rolled back in the database. + +When you check the `IssueAppService`, you will see the advantage of **not saving** `Issue` to the database in the `IssueManager.CreateAsync`. Otherwise, we would need to perform one *Insert* (in the `IssueManager`) and one *Update* (after the Assignment). + +##### Discussion: Why is the duplicate Title check not implemented in the Application Service? + +We could simple say "Because it is a **core domain logic** and should be implemented in the Domain Layer". However, it brings a new question "**How did you decide** that it is a core domain logic, but not an application logic?" (we will discuss the difference later with more details). + +For this example, a simple question can help us to make the decision: "If we have another way (use case) of creating an issue, should we still apply the same rule? Is that rule should *always* be implemented". You may think "Why do we have a second way of creating an issue?". However, in real life, you have; + +* **End users** of the application may create issues in your application's standard UI. +* You may have a second **back office** application that is used by your own employees and you may want to provide a way of creating issues (probably with different authorization rules in this case). +* You may have an HTTP API that is open to **3rd-party clients** and they create issues. +* You may have a **background worker** service that do something and creates issues if it detects some problems. In this way, it will create an issue without any user interaction (and probably without any standard authorization check). +* You may have a button on the UI that **converts** something (for example, a discussion) to an issue. + +We can give more examples. All of these are should be implemented by **different Application Service methods** (see the *Multiple Application Layers* section below), but they **always** follow the rule: Title of the new issue can not be same of any existing issue! That's why this logic is a **core domain logic**, should be located in the Domain Layer and **should not be duplicated** in all these application service methods. + +### Updating / Manipulating An Entity + +Once an entity is created, it is updated/manipulated by the use cases until it is deleted from the system. There can be different types of the use cases directly or indirectly changes an entity. + +In this section, we will discuss a typical update operation that changes multiple properties of an `Issue`. + +This time, beginning from the *Update* DTO: + +````csharp +public class UpdateIssueDto +{ + [Required] + public string Title { get; set; } + public string Text { get; set; } + public Guid? AssignedUserId { get; set; } +} +```` + +By comparing to `IssueCreationDto`, you see no `RepositoryId`. Because, our system doesn't allow to move issues across repositories (think as GitHub repositories). Only `Title` is required and the other properties are optional. + +Let's see the *Update* implementation in the `IssueAppService`: + +````csharp +public class IssueAppService : ApplicationService, IIssueAppService +{ + private readonly IssueManager _issueManager; + private readonly IRepository _issueRepository; + private readonly IRepository _userRepository; + + public IssueAppService( + IssueManager issueManager, + IRepository issueRepository, + IRepository userRepository) + { + _issueManager = issueManager; + _issueRepository = issueRepository; + _userRepository = userRepository; + } + + public async Task UpdateAsync(Guid id, UpdateIssueDto input) + { + // Get entity from database + var issue = await _issueRepository.GetAsync(id); + + // Change Title + await _issueManager.ChangeTitleAsync(issue, input.Title); + + // Change Assigned User + if (input.AssignedUserId.HasValue) + { + var user = await _userRepository.GetAsync(input.AssignedUserId.Value); + await _issueManager.AssignToAsync(issue, user); + } + + // Change Text (no business rule, all values accepted) + issue.Text = input.Text; + + // Update entity in the database + await _issueRepository.UpdateAsync(issue); + + // Return a DTO represents the new Issue + return ObjectMapper.Map(issue); + } +} +```` + +* `UpdateAsync` method gets `id` as a separate parameter. It is not included in the `UpdateIssueDto`. This is a design decision that helps ABP to properly define HTTP routes when you [auto expose](API/Auto-API-Controllers.md) this service as an HTTP API endpoint. So, that's not related to DDD. +* It starts by **getting** the `Issue` entity **from the database**. +* Uses `IssueManager`'s `ChangeTitleAsync` instead of directly calling `Issue.SetTitle(...)`. Because we need to implement the **duplicate Title check** as just done in the *Entity Creation*. This requires some changes in the `Issue` and `IssueManager` classes (will be explained below). +* Uses `IssueManager`'s `AssignToAsync` method if the **assigned user** is being changed with this request. +* Directly sets the `Issue.Text` since there is **no business rule** for that. If we need later, we can always refactor. +* **Saves changes** to the database. Again, saving changed entities is a responsibility of the Application Service method that coordinates the business objects and the transaction. If the `IssueManager` had saved internally in `ChangeTitleAsync` and `AssignToAsync` method, there would be double database operation (see the *Discussion: Why is the Issue not saved to the database in `IssueManager`?* above). +* Finally uses the `IObjectMapper` to return an `IssueDto` that is automatically created by **mapping** from the updated `Issue` entity. + +As said, we need some changes in the `Issue` and `IssueManager` classes. + +First, made `SetTitle` internal in the `Issue` class: + +````csharp +internal void SetTitle(string title) +{ + Title = Check.NotNullOrWhiteSpace(title, nameof(title)); +} +```` + +Then added a new method to the `IssueManager` to change the Title: + +````csharp +public async Task ChangeTitleAsync(Issue issue, string title) +{ + if (issue.Title == title) + { + return; + } + + if (await _issueRepository.AnyAsync(i => i.Title == title)) + { + throw new BusinessException("IssueTracking:IssueWithSameTitleExists"); + } + + issue.SetTitle(title); +} +```` + +## Domain Logic & Application Logic + +As mentioned before, *Business Logic* in the Domain Driven Design is spitted into two parts (layers): *Domain Logic* and *Application Logic*: + +![domain-driven-design-domain-vs-application-logic](images/domain-driven-design-domain-vs-application-logic.png) + +Domain Logic consists of the *Core Domain Rules* of the system while Application Logic implements application specific *Use Cases*. + +While the definition is clear, the implementation may not be easy. You may be undecided which code should stand in the Application Layer, which code should be in the Domain Layer. This section tries to explain the differences. + +### Multiple Application Layers + +DDD helps to **deal with complexity** when your system is large. Especially, if there are **multiple applications** are being developed in a **single domain,** then the **Domain Logic vs Application Logic separation** becomes much more important. + +Assume that you are building a system that has multiple applications; + +* A **Public Web Site Application**, built with ASP.NET Core MVC, to show your products to users. Such a web site doesn't require authentication to see the products. The users login to the web site, only if they are performing some actions (like adding a product to the basket). +* A **Back Office Application**, built with Angular UI (that uses REST APIs). This application used by office workers of the company to manage the system (like editing product descriptions). +* A **Mobile Application** that has much simpler UI compared to the Public Web Site. It may communicate to the server via REST APIs or another technology (like TCP sockets). + +![domain-driven-design-multiple-applications](images/domain-driven-design-multiple-applications.png) + +Every application will have different **requirements**, different **use cases** (Application Service methods), different **DTOs**, different **validation** and **authorization** rules... etc. + +Mixing all these logics into a single application layer makes your services contain too many `if` conditions with **complicated business logic** makes your code **harder to develop, maintain and test** and leads to potential bugs. + +If you've multiple applications with a single domain; + +* Create **separate application layers** for each application/client type and implement application specific business logic in these separate layers. +* Use a **single domain layer** to share the core domain logic. + +Such a design makes it even more important to distinguish between Domain logic and Application Logic. + +To be more clear about the implementation, you can create different projects (`.csproj`) for each application types. For example; + +* `IssueTracker.Admin.Application` & `IssueTracker.Admin.Application.Contacts` projects for the Back Office (admin) Application. +* `IssueTracker.Public.Application` & `IssueTracker.Public.Application.Contracts` projects for the Public Web Application. +* `IssueTracker.Mobile.Application` & `IssueTracker.Mobile.Application.Contracts` projects for the Mobile Application. + +### Examples + +This section contains some Application Service and Domain Service examples to discuss how to decide to place business logic inside these services. + +**Example: Creating a new `Organization` in a Domain Service** + +````csharp +public class OrganizationManager : DomainService +{ + private readonly IRepository _organizationRepository; + private readonly ICurrentUser _currentUser; + private readonly IAuthorizationService _authorizationService; + private readonly IEmailSender _emailSender; + + public OrganizationManager( + IRepository organizationRepository, + ICurrentUser currentUser, + IAuthorizationService authorizationService, + IEmailSender emailSender) + { + _organizationRepository = organizationRepository; + _currentUser = currentUser; + _authorizationService = authorizationService; + _emailSender = emailSender; + } + + public async Task CreateAsync(string name) + { + if (await _organizationRepository.AnyAsync(x => x.Name == name)) + { + throw new BusinessException("IssueTracking:DuplicateOrganizationName"); + } + + await _authorizationService.CheckAsync("OrganizationCreationPermission"); + + Logger.LogDebug($"Creating organization {name} by {_currentUser.UserName}"); + + var organization = new Organization(); + + await _emailSender.SendAsync( + "systemadmin@issuetracking.com", + "New Organization", + "A new organization created with name: " + name + ); + + return organization; + } +} +```` + +Let's see the `CreateAsync` method step by step to discuss if the code part should be in the Domain Service, or not; + +* **CORRECT**: It first checks for **duplicate organization name** and and throws exception in this case. This is something related to core domain rule and we never allow duplicated names. +* **WRONG**: Domain Services should not perform **authorization**. [Authorization](Authorization.md) should be done in the Application Layer. +* **WRONG**: It logs a message with including the [Current User](CurrentUser.md)'s `UserName`. Domain service should not be depend on the Current User. Domain Services should be usable even if there is no user in the system. Current User (Session) should be a Presentation/Application Layer related concept. +* **WRONG**: It sends an [email](Emailing.md) about this new organization creation. We think this is also a use case specific business logic. You may want to create different type of emails in different use cases or don't need to send emails in some cases. + +**Example: Creating a new `Organization` in an Application Service** + +````csharp +public class OrganizationAppService : ApplicationService +{ + private readonly OrganizationManager _organizationManager; + private readonly IPaymentService _paymentService; + private readonly IEmailSender _emailSender; + + public OrganizationAppService( + OrganizationManager organizationManager, + IPaymentService paymentService, + IEmailSender emailSender) + { + _organizationManager = organizationManager; + _paymentService = paymentService; + _emailSender = emailSender; + } + + [UnitOfWork] + [Authorize("OrganizationCreationPermission")] + public async Task CreateAsync(CreateOrganizationDto input) + { + await _paymentService.ChargeAsync( + CurrentUser.Id, + GetOrganizationPrice() + ); + + var organization = await _organizationManager.CreateAsync(input.Name); + + await _organizationManager.InsertAsync(organization); + + await _emailSender.SendAsync( + "systemadmin@issuetracking.com", + "New Organization", + "A new organization created with name: " + input.Name + ); + + return organization; // !!! + } + + private double GetOrganizationPrice() + { + return 42; //Gets from somewhere else... + } +} +```` + +Let's see the `CreateAsync` method step by step to discuss if the code part should be in the Application Service, or not; + +* **CORRECT**: Application Service methods should be unit of work (transactional). ABP's [Unit Of Work](Unit-Of-Work.md) system makes this automatic (even without need to add `[UnitOfWork]` attribute for the Application Services). +* **CORRECT**: [Authorization](Authorization.md) should be done in the application layer. Here, it is done by using the `[Authorize]` attribute. +* **CORRECT**: Payment (an infrastructure service) is called to charge money for this operation (Creating an Organization is a paid service in our business). +* **CORRECT**: Application Service method is responsible to save changes to the database. +* **CORRECT**: We can send [email](Emailing.md) as a notification to the system admin. +* **WRONG**: Do not return entities from the Application Services. Return a DTO instead. + +**Discussion: Why don't we move the payment logic into the domain service?** + +You may wonder why the payment code is not inside the `OrganizationManager`. It is an **important thing** and we never want to **miss the payment**. + +However, **being important is not sufficient** to consider a code as a Core Business Logic. We may have **other use cases** where we don't charge money to create a new Organization. Examples; + +* An admin user can use a Back Office Application to create a new organization without any payment. +* A background-working data import/integration/synchronization system may also need to create organizations without any payment operation. + +As you see, **payment is not a necessary operation to create a valid organization**. It is a use-case specific application logic. + +**Example: CRUD Operations** + +````csharp +public class IssueAppService +{ + private readonly IssueManager _issueManager; + + public IssueAppService(IssueManager issueManager) + { + _issueManager = issueManager; + } + + public async Task GetAsync(Guid id) + { + return await _issueManager.GetAsync(id); + } + + public async Task CreateAsync(IssueCreationDto input) + { + await _issueManager.CreateAsync(input); + } + + public async Task UpdateAsync(UpdateIssueDto input) + { + await _issueManager.UpdateAsync(input); + } + + public async Task DeleteAsync(Guid id) + { + await _issueManager.DeleteAsync(id); + } +} +```` + +This Application Service **does nothing** itself and **delegates all the work** to the *Domain Service*. It even passes the DTOs to the `IssueManager`. + +* **Do not** create Domain Service methods just for simple **CRUD** operations **without any domain logic**. +* **Never** pass **DTOs** to or return **DTOs** from the Domain Services. + +Application Services can directly work with repositories to query, create, update or delete data unless there are some domain logics should be performed during these operations. In such cases, create Domain Service methods, but only for those really necessary. + +> Do not create such CRUD domain service methods just by thinking that they may be needed in the future ([YAGNI](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it))! Do it when you need and refactor the existing code. Since the Application Layer gracefully abstracts the Domain Layer, the refactoring process doesn't effect the UI Layer and other clients. + +## Reference Books + +If you are more interested in the Domain Driven Design and building large-scale enterprise systems, the following books are recommended as reference books; + +* "*Domain Driven Design*" by Eric Evans +* "*Implementing Domain Driven Design*" by Vaughn Vernon +* "*Clean Architecture*" by Robert C. Martin diff --git a/docs/en/Domain-Driven-Design.md b/docs/en/Domain-Driven-Design.md index f3d2699cab..f18c1882ef 100644 --- a/docs/en/Domain-Driven-Design.md +++ b/docs/en/Domain-Driven-Design.md @@ -10,7 +10,7 @@ ABP framework provides an **infrastructure** to make **Domain Driven Design** ba > - Basing complex designs on a model of the domain; > - Initiating a creative collaboration between technical and domain experts to iteratively refine a conceptual model that addresses particular domain problems. -### Layers +## Layers & Building Blocks ABP follows DDD principles and patterns to achieve a layered application model which consists of four fundamental layers: @@ -19,11 +19,7 @@ ABP follows DDD principles and patterns to achieve a layered application model w - **Domain Layer**: Includes business objects and the core (domain) business rules. This is the heart of the application. - **Infrastructure Layer**: Provides generic technical capabilities that support higher layers mostly using 3rd-party libraries. -DDD mostly interest in the **Domain** and the **Application** layers, rather than the Infrastructure and the Presentation layers. - -## Contents - -See the following documents to learn what ABP Framework provides to you to implement DDD in your project. +DDD mostly interest in the **Domain** and the **Application** layers, rather than the Infrastructure and the Presentation layers. The following documents explains the **infrastructure** provided by the ABP Framework to implement **Building Blocks** of the DDD: * **Domain Layer** * [Entities & Aggregate Roots](Entities.md) @@ -34,4 +30,8 @@ See the following documents to learn what ABP Framework provides to you to imple * **Application Layer** * [Application Services](Application-Services.md) * [Data Transfer Objects (DTOs)](Data-Transfer-Objects.md) - * [Unit of Work](Unit-Of-Work.md) \ No newline at end of file + * [Unit of Work](Unit-Of-Work.md) + +## The Ultimate DDD Implementation Guide + +See the [Implementing Domain Driven Design](Domain-Driven-Design-Implementation-Guide.md) guide as a **complete reference**. The Guide explains the Domain Driven Design and introduces explicit **rules and examples** to give a deep understanding of the **implementation details**. \ No newline at end of file diff --git a/docs/en/Entity-Framework-Core.md b/docs/en/Entity-Framework-Core.md index 98163e7c28..8c0a1c9cc9 100644 --- a/docs/en/Entity-Framework-Core.md +++ b/docs/en/Entity-Framework-Core.md @@ -92,7 +92,7 @@ protected override void OnModelCreating(ModelBuilder builder) b.ToTable("Books"); //Configure the base properties - b.ConfigureByConvention(); + b.ConfigureByConvention(); //Configure other properties (if you are using the fluent API) b.Property(x => x.Name).IsRequired().HasMaxLength(128); @@ -113,7 +113,7 @@ If you have multiple databases in your application, you can configure the connec [ConnectionStringName("MySecondConnString")] public class MyDbContext : AbpDbContext { - + } ``` @@ -174,7 +174,7 @@ public class Book : AggregateRoot } ``` -(`BookType` is a simple enum here) And you want to create a new `Book` entity in a [domain service](Domain-Services.md): +(`BookType` is a simple `enum` here and not important) And you want to create a new `Book` entity in a [domain service](Domain-Services.md): ````csharp public class BookManager : DomainService @@ -221,12 +221,13 @@ public interface IBookRepository : IRepository } ```` -You generally want to derive from the `IRepository` to inherit standard repository methods. However, you don't have to. Repository interfaces are defined in the domain layer of a layered application. They are implemented in the data/infrastructure layer (`EntityFrameworkCore` project in a [startup template](https://abp.io/Templates)). +You generally want to derive from the `IRepository` to inherit standard repository methods (while, you don't have to do). Repository interfaces are defined in the domain layer of a layered application. They are implemented in the data/infrastructure layer (`EntityFrameworkCore` project in a [startup template](https://abp.io/Templates)). Example implementation of the `IBookRepository` interface: ````csharp -public class BookRepository : EfCoreRepository, IBookRepository +public class BookRepository + : EfCoreRepository, IBookRepository { public BookRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) @@ -254,7 +255,7 @@ If you want to replace default repository implementation with your custom reposi context.Services.AddAbpDbContext(options => { options.AddDefaultRepositories(); - + //Replaces IRepository options.AddRepository(); }); @@ -263,7 +264,7 @@ context.Services.AddAbpDbContext(options => This is especially important when you want to **override a base repository method** to customize it. For instance, you may want to override `DeleteAsync` method to delete a specific entity in a more efficient way: ````csharp -public override async Task DeleteAsync( +public async override Task DeleteAsync( Guid id, bool autoSave = false, CancellationToken cancellationToken = default) @@ -272,6 +273,278 @@ public override async Task DeleteAsync( } ```` +## Loading Related Entities + +Assume that you've an `Order` with a collection of `OrderLine`s and the `OrderLine` has a navigation property to the `Order`: + +````csharp +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Volo.Abp.Auditing; +using Volo.Abp.Domain.Entities; + +namespace MyCrm +{ + public class Order : AggregateRoot, IHasCreationTime + { + public Guid CustomerId { get; set; } + public DateTime CreationTime { get; set; } + + public ICollection Lines { get; set; } //Sub collection + + public Order() + { + Lines = new Collection(); + } + } + + public class OrderLine : Entity + { + public Order Order { get; set; } //Navigation property + public Guid OrderId { get; set; } + + public Guid ProductId { get; set; } + public int Count { get; set; } + public double UnitPrice { get; set; } + } +} + +```` + +And defined the database mapping as shown below: + +````csharp +builder.Entity(b => +{ + b.ToTable("Orders"); + b.ConfigureByConvention(); + + //Define the relation + b.HasMany(x => x.Lines) + .WithOne(x => x.Order) + .HasForeignKey(x => x.OrderId) + .IsRequired(); +}); + +builder.Entity(b => +{ + b.ToTable("OrderLines"); + b.ConfigureByConvention(); +}); +```` + +When you query an `Order`, you may want to **include** all the `OrderLine`s in a single query or you may want to **load them later** on demand. + +> Actually these are not directly related to the ABP Framework. You can follow the [EF Core documentation](https://docs.microsoft.com/en-us/ef/core/querying/related-data/) to learn all the details. This section will cover some topics related to the ABP Framework. + +### Eager Loading / Load With Details + +You have different options when you want to load the related entities while querying an entity. + +#### Repository.WithDetails + +`IRepository.WithDetails(...)` can be used to include one relation collection/property to the query. + +**Example: Get an order with lines** + +````csharp +using System; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Domain.Services; + +namespace MyCrm +{ + public class OrderManager : DomainService + { + private readonly IRepository _orderRepository; + + public OrderManager(IRepository orderRepository) + { + _orderRepository = orderRepository; + } + + public async Task TestWithDetails(Guid id) + { + var query = _orderRepository + .WithDetails(x => x.Lines) + .Where(x => x.Id == id); + + var order = await AsyncExecuter.FirstOrDefaultAsync(query); + } + } +} +```` + +> `AsyncExecuter` is used to execute async LINQ extensions without depending on the EF Core. If you add EF Core NuGet package reference to your project, then you can directly use `await _orderRepository.WithDetails(x => x.Lines).FirstOrDefaultAsync()`. But, this time you depend on the EF Core in your domain layer. See the [repository document](Repositories.md) to learn more. + +**Example: Get a list of orders with their lines** + +````csharp +public async Task TestWithDetails() +{ + var query = _orderRepository + .WithDetails(x => x.Lines); + + var orders = await AsyncExecuter.ToListAsync(query); +} +```` + +> `WithDetails` method can get more than one expression parameter if you need to include more than one navigation property or collection. + +#### DefaultWithDetailsFunc + +If you don't pass any expression to the `WithDetails` method, then it includes all the details using the `DefaultWithDetailsFunc` option you provide. + +You can configure `DefaultWithDetailsFunc` for an entity in the `ConfigureServices` method of your [module](Module-Development-Basics.md) in your `EntityFrameworkCore` project. + +**Example: Include `Lines` while querying an `Order`** + +````csharp +Configure(options => +{ + options.Entity(orderOptions => + { + orderOptions.DefaultWithDetailsFunc = query => query.Include(o => o.Lines); + }); +}); +```` + +> You can fully use the EF Core API here since this is located in the EF Core integration project. + +Then you can use the `WithDetails` without any parameter: + +````csharp +public async Task TestWithDetails() +{ + var query = _orderRepository.WithDetails(); + var orders = await AsyncExecuter.ToListAsync(query); +} +```` + +`WithDetails()` executes the expression you've setup as the `DefaultWithDetailsFunc`. + +#### Repository Get/Find Methods + +Some of the standard [Repository](Repositories.md) methods have optional `includeDetails` parameters; + +* `GetAsync` and `FindAsync` gets `includeDetails` with default value is `true`. +* `GetListAsync` and `GetPagedListAsync` gets `includeDetails` with default value is `false`. + +That means, the methods return a **single entity includes details** by default while list returning methods don't include details by default. You can explicitly pass `includeDetails` to change the behavior. + +> These methods use the `DefaultWithDetailsFunc` option that is explained above. + +**Example: Get an order with details** + +````csharp +public async Task TestWithDetails(Guid id) +{ + var order = await _orderRepository.GetAsync(id); +} +```` + +**Example: Get an order without details** + +````csharp +public async Task TestWithoutDetails(Guid id) +{ + var order = await _orderRepository.GetAsync(id, includeDetails: false); +} +```` + +**Example: Get list of entities with details** + +````csharp +public async Task TestWithDetails() +{ + var orders = await _orderRepository.GetListAsync(includeDetails: true); +} +```` + +#### Alternatives + +The repository patters tries to encapsulate the EF Core, so your options are limited. If you need an advanced scenario, you can follow one of the options; + +* Create a custom repository method and use the complete EF Core API. +* Reference to the `Volo.Abp.EntityFrameworkCore` package from your project. In this way, you can directly use `Include` and `ThenInclude` in your code. + +See also [eager loading document](https://docs.microsoft.com/en-us/ef/core/querying/related-data/eager) of the EF Core. + +### Explicit / Lazy Loading + +If you don't include relations while querying an entity and later need to access to a navigation property or collection, you have different options. + +#### EnsurePropertyLoadedAsync / EnsureCollectionLoadedAsync + +Repositories provide `EnsurePropertyLoadedAsync` and `EnsureCollectionLoadedAsync` extension methods to **explicitly load** a navigation property or sub collection. + +**Example: Load Lines of an Order when needed** + +````csharp +public async Task TestWithDetails(Guid id) +{ + var order = await _orderRepository.GetAsync(id, includeDetails: false); + //order.Lines is empty on this stage + + await _orderRepository.EnsureCollectionLoadedAsync(order, x => x.Lines); + //order.Lines is filled now +} +```` + +`EnsurePropertyLoadedAsync` and `EnsureCollectionLoadedAsync` methods do nothing if the property or collection was already loaded. So, calling multiple times has no problem. + +See also [explicit loading document](https://docs.microsoft.com/en-us/ef/core/querying/related-data/explicit) of the EF Core. + +#### Lazy Loading with Proxies + +Explicit loading may not be possible in some cases, especially when you don't have a reference to the `Repository` or `DbContext`. Lazy Loading is a feature of the EF Core that loads the related properties / collections when you first access to it. + +To enable lazy loading; + +1. Install the [Microsoft.EntityFrameworkCore.Proxies](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Proxies/) package into your project (typically to the EF Core integration project) +2. Configure `UseLazyLoadingProxies` for your `DbContext` (in the `ConfigureServices` method of your module in your EF Core project). Example: + +````csharp +Configure(options => +{ + options.PreConfigure(opts => + { + opts.DbContextOptions.UseLazyLoadingProxies(); //Enable lazy loading + }); + + options.UseSqlServer(); +}); +```` + +3. Make your navigation properties and collections `virtual`. Examples: + +````csharp +public virtual ICollection Lines { get; set; } //virtual collection +public virtual Order Order { get; set; } //virtual navigation property +```` + +Once you enable lazy loading and arrange your entities, you can freely access to the navigation properties and collections: + +````csharp +public async Task TestWithDetails(Guid id) +{ + var order = await _orderRepository.GetAsync(id); + //order.Lines is empty on this stage + + var lines = order.Lines; + //order.Lines is filled (lazy loaded) +} +```` + +Whenever you access to a property/collection, EF Core automatically performs an additional query to load the property/collection from the database. + +> Lazy loading should be carefully used since it may cause performance problems in some specific cases. + +See also [lazy loading document](https://docs.microsoft.com/en-us/ef/core/querying/related-data/lazy) of the EF Core. + ## Access to the EF Core API In most cases, you want to hide EF Core APIs behind a repository (this is the main purpose of the repository pattern). However, if you want to access the `DbContext` instance over the repository, you can use `GetDbContext()` or `GetDbSet()` extension methods. Example: @@ -296,7 +569,7 @@ public class BookService * `GetDbContext` returns a `DbContext` reference instead of `BookStoreDbContext`. You can cast it, however in most cases you don't need it. -> Important: You must reference to the `Volo.Abp.EntityFrameworkCore` package from the project you want to access to the DbContext. This breaks encapsulation, but this is what you want in that case. +> Important: You must reference to the `Volo.Abp.EntityFrameworkCore` package from the project you want to access to the `DbContext`. This breaks encapsulation, but this is what you want in that case. ## Extra Properties & Object Extension Manager @@ -365,7 +638,7 @@ public class MyRepositoryBase : EfCoreRepository where TEntity : class, IEntity { - public MyRepositoryBase(IDbContextProvider dbContextProvider) + public MyRepositoryBase(IDbContextProvider dbContextProvider) : base(dbContextProvider) { } @@ -395,7 +668,7 @@ context.Services.AddAbpDbContext(options => typeof(MyRepositoryBase<,>), typeof(MyRepositoryBase<>) ); - + //... }); ``` @@ -446,6 +719,22 @@ context.Services.AddAbpDbContext(options => In this example, `OtherDbContext` implements `IBookStoreDbContext`. This feature allows you to have multiple DbContext (one per module) on development, but single DbContext (implements all interfaces of all DbContexts) on runtime. +### Split Queries + +ABP enables [split queries](https://docs.microsoft.com/en-us/ef/core/querying/single-split-queries) globally by default for better performance. You can change it as needed. + +**Example** + +````csharp +Configure(options => +{ + options.UseSqlServer(optionsBuilder => + { + optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SingleQuery); + }); +}); +```` + ## See Also -* [Entities](Entities.md) \ No newline at end of file +* [Entities](Entities.md) diff --git a/docs/en/Exception-Handling.md b/docs/en/Exception-Handling.md index 59a2c6bd0e..8c84157878 100644 --- a/docs/en/Exception-Handling.md +++ b/docs/en/Exception-Handling.md @@ -1,11 +1,11 @@ # Exception Handling -ABP provides a built-in infrastructure and offers a standard model for handling exceptions in a web application. +ABP provides a built-in infrastructure and offers a standard model for handling exceptions. * Automatically **handles all exceptions** and sends a standard **formatted error message** to the client for an API/AJAX request. * Automatically hides **internal infrastructure errors** and returns a standard error message. -* Provides a configurable way to **localize** exception messages. -* Automatically maps standard exceptions to **HTTP status codes** and provides a configurable option to map these to custom exceptions. +* Provides an easy and configurable way to **localize** exception messages. +* Automatically maps standard exceptions to **HTTP status codes** and provides a configurable option to map custom exceptions. ## Automatic Exception Handling @@ -85,7 +85,7 @@ Error **details** in an optional field of the JSON error message. Thrown `Except ### Logging -Caught exceptions are automatically logged. +Caught exceptions are automatically logged. #### Log Level @@ -300,7 +300,7 @@ In this case, create a class derived from the `ExceptionSubscriber` class in you ````csharp public class MyExceptionSubscriber : ExceptionSubscriber { - public override async Task HandleAsync(ExceptionNotificationContext context) + public async override Task HandleAsync(ExceptionNotificationContext context) { //TODO... } diff --git a/docs/en/Getting-Started-AspNetCore-Application.md b/docs/en/Getting-Started-AspNetCore-Application.md index 9698b1dfb0..9202ed29f1 100644 --- a/docs/en/Getting-Started-AspNetCore-Application.md +++ b/docs/en/Getting-Started-AspNetCore-Application.md @@ -4,7 +4,7 @@ This tutorial explains how to start ABP from scratch with minimal dependencies. ## Create A New Project -1. Create a new AspNet Core Web Application from Visual Studio 2019 (16.4.0+): +1. Create a new AspNet Core Web Application from Visual Studio 2019 (16.8.0+): ![](images/create-new-aspnet-core-application-v2.png) diff --git a/docs/en/Getting-Started-Create-Solution.md b/docs/en/Getting-Started-Create-Solution.md new file mode 100644 index 0000000000..75a50a737f --- /dev/null +++ b/docs/en/Getting-Started-Create-Solution.md @@ -0,0 +1,65 @@ +# Getting Started + +````json +//[doc-params] +{ + "UI": ["MVC", "Blazor", "NG"], + "DB": ["EF", "Mongo"], + "Tiered": ["Yes", "No"] +} +```` + +> This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. For other options, please change the preference on top of this document. + +## Create a New Project + +Use the `new` command of the ABP CLI to create a new project: + +````shell +abp new Acme.BookStore{{if UI == "NG"}} -u angular{{else if UI == "Blazor"}} -u blazor{{end}}{{if DB == "Mongo"}} -d mongodb{{end}}{{if Tiered == "Yes"}}{{if UI == "MVC"}} --tiered{{else}} --separate-identity-server{{end}}{{end}} +```` + +*You can use different level of namespaces; e.g. BookStore, Acme.BookStore or Acme.Retail.BookStore.* + +{{ if Tiered == "Yes" }} + +{{ if UI == "MVC" }} + +* `--tiered` argument is used to create N-tiered solution where authentication server, UI and API layers are physically separated. + +{{ else }} + +* `--separate-identity-server` argument is used to separate the identity server application from the API host application. If not specified, you will have a single endpoint on the server. + +{{ end }} + +{{ end }} + +> [ABP CLI document](./CLI.md) covers all of the available commands and options. + +> Alternatively, you can **create and download** projects from [ABP Framework website](https://abp.io/get-started) by easily selecting the all the options from the page. + +### The Solution Structure + +The solution has a layered structure (based on the [Domain Driven Design](Domain-Driven-Design.md)) and contains unit & integration test projects. See the [application template document](Startup-Templates/Application.md) to understand the solution structure in details. + +{{ if DB == "Mongo" }} + +#### MongoDB Transactions + +The [startup template](Startup-templates/Index.md) **disables** transactions in the `.MongoDB` project by default. If your MongoDB server supports transactions, you can enable the it in the *YourProjectMongoDbModule* class's `ConfigureServices` method: + + ```csharp +Configure(options => +{ + options.TransactionBehavior = UnitOfWorkTransactionBehavior.Auto; +}); + ``` + +> Or you can delete that code since `Auto` is already the default behavior. + +{{ end }} + +## Next Step + +* [Running the solution](Getting-Started-Running-Solution.md) \ No newline at end of file diff --git a/docs/en/Getting-Started-React-Native.md b/docs/en/Getting-Started-React-Native.md index a06257fec9..08faac3608 100644 --- a/docs/en/Getting-Started-React-Native.md +++ b/docs/en/Getting-Started-React-Native.md @@ -27,13 +27,13 @@ You have multiple options to initiate a new React Native project that works with ### 1. Using ABP CLI -ABP CLI is probably the most convenient and flexible way to initiate an ABP solution with a React Native application. Simply [install the ABP CLI](../../CLI.md) and run the following command in your terminal: +ABP CLI is probably the most convenient and flexible way to initiate an ABP solution with a React Native application. Simply [install the ABP CLI](CLI.md) and run the following command in your terminal: ```shell abp new MyCompanyName.MyProjectName -csf -u -m react-native ``` -> To see further options in the CLI, please visit the [CLI manual](../../CLI.md). +> To see further options in the CLI, please visit the [CLI manual](CLI.md). This command will prepare a solution with an **Angular** or an **MVC** (depends on your choice), a **.NET Core**, and a **React Native** project in it. diff --git a/docs/en/Getting-Started-Running-Solution.md b/docs/en/Getting-Started-Running-Solution.md new file mode 100644 index 0000000000..d1f02c887b --- /dev/null +++ b/docs/en/Getting-Started-Running-Solution.md @@ -0,0 +1,217 @@ +# Getting Started + +````json +//[doc-params] +{ + "UI": ["MVC", "Blazor", "NG"], + "DB": ["EF", "Mongo"], + "Tiered": ["Yes", "No"] +} +```` + +> This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. For other options, please change the preference on top of this document. + +## Create the Database + +### Connection String + +Check the **connection string** in the `appsettings.json` file under the {{if Tiered == "Yes"}}`.IdentityServer` and `.HttpApi.Host` projects{{else}}{{if UI=="MVC"}}`.Web` project{{else}}`.HttpApi.Host` project{{end}}{{end}} + +{{ if DB == "EF" }} + +````json +"ConnectionStrings": { + "Default": "Server=localhost;Database=BookStore;Trusted_Connection=True" +} +```` + +The solution is configured to use **Entity Framework Core** with **MS SQL Server** by default. EF Core supports [various](https://docs.microsoft.com/en-us/ef/core/providers/) database providers, so you can use any supported DBMS. See [the Entity Framework integration document](Entity-Framework-Core.md) to learn how to [switch to another DBMS](Entity-Framework-Core-Other-DBMS.md). + +### Apply the Migrations + +The solution uses the [Entity Framework Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli). So, you need to apply migrations to create the database. There are two ways of applying the database migrations. + +#### Apply Migrations Using the DbMigrator + +The solution comes with a `.DbMigrator` console application which applies migrations and also **seeds the initial data**. It is useful on **development** as well as on **production** environment. + +> `.DbMigrator` project has its own `appsettings.json`. So, if you have changed the connection string above, you should also change this one. + +Right click to the `.DbMigrator` project and select **Set as StartUp Project** + +![set-as-startup-project](images/set-as-startup-project.png) + + Hit F5 (or Ctrl+F5) to run the application. It will have an output like shown below: + + ![db-migrator-output](images/db-migrator-output.png) + +> Initial [seed data](Data-Seeding.md) creates the `admin` user in the database (with the password is `1q2w3E*`) which is then used to login to the application. So, you need to use `.DbMigrator` at least once for a new database. + +#### Using EF Core Update-Database Command + +Ef Core has `Update-Database` command which creates database if necessary and applies pending migrations. + +{{ if UI == "MVC" }} + +Right click to the {{if Tiered == "Yes"}}`.IdentityServer`{{else}}`.Web`{{end}} project and select **Set as StartUp project**: + +{{ else if UI != "MVC" }} + +Right click to the `.HttpApi.Host` project and select **Set as StartUp Project**: + +{{ end }} + +![set-as-startup-project](images/set-as-startup-project.png) + +Open the **Package Manager Console**, select `.EntityFrameworkCore.DbMigrations` project as the **Default Project** and run the `Update-Database` command: + +![package-manager-console-update-database](images/package-manager-console-update-database.png) + +This will create a new database based on the configured connection string. + +> **Using the `.DbMigrator` tool is the suggested way**, because it also seeds the initial data to be able to properly run the web application. +> +> If you just use the `Update-Database` command, you will have an empty database, so you can not login to the application since there is no initial admin user in the database. You can use the `Update-Database` command in development time when you don't need to seed the database. However, using the `.DbMigrator` application is easier and you can always use it to migrate the schema and seed the database. + +{{ else if DB == "Mongo" }} + +````json +"ConnectionStrings": { + "Default": "mongodb://localhost:27017/BookStore" +} +```` + +The solution is configured to use **MongoDB** in your local computer, so you need to have a MongoDB server instance up and running or change the connection string to another MongoDB server. + +### Seed Initial Data + +The solution comes with a `.DbMigrator` console application which **seeds the initial data**. It is useful on **development** as well as on **production** environment. + +> `.DbMigrator` project has its own `appsettings.json`. So, if you have changed the connection string above, you should also change this one. + +Right click to the `.DbMigrator` project and select **Set as StartUp Project** + +![set-as-startup-project](images/set-as-startup-project.png) + + Hit F5 (or Ctrl+F5) to run the application. It will have an output like shown below: + + ![db-migrator-output](images/db-migrator-output.png) + +> Initial [seed data](Data-Seeding.md) creates the `admin` user in the database (with the password is `1q2w3E*`) which is then used to login to the application. So, you need to use `.DbMigrator` at least once for a new database. + +{{ end }} + +## Run the Application + +{{ if UI == "MVC" }} + +{{ if Tiered == "Yes" }} + +> Tiered solutions use **Redis** as the distributed cache. Ensure that it is installed and running in your local computer. If you are using a remote Redis Server, set the configuration in the `appsettings.json` files of the projects below. + +1. Ensure that the `.IdentityServer` project is the startup project. Run this application that will open a **login** page in your browser. + +> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. + +You can login, but you cannot enter to the main application here. This is **just the authentication server**. + +2. Ensure that the `.HttpApi.Host` project is the startup project and run the application which will open a **Swagger UI** in your browser. + +![swagger-ui](images/swagger-ui.png) + +This is the HTTP API that is used by the web application. + +3. Lastly, ensure that the `.Web` project is the startup project and run the application which will open a **welcome** page in your browser + +![mvc-tiered-app-home](images/bookstore-home.png) + +Click to the **login** button which will redirect you to the *authentication server* to login to the application: + +![bookstore-login](images/bookstore-login.png) + +{{ else # Tiered != "Yes" }} + +Ensure that the `.Web` project is the startup project. Run the application which will open the **login** page in your browser: + +> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. + +![bookstore-login](images/bookstore-login.png) + +{{ end # Tiered }} + +{{ else # UI != "MVC" }} + +### Running the HTTP API Host (Server Side) + +{{ if Tiered == "Yes" }} + +> Tiered solutions use Redis as the distributed cache. Ensure that it is installed and running in your local computer. If you are using a remote Redis Server, set the configuration in the `appsettings.json` files of the projects below. + +Ensure that the `.IdentityServer` project is the startup project. Run the application which will open a **login** page in your browser. + +> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. + +You can login, but you cannot enter to the main application here. This is just the authentication server. + +Ensure that the `.HttpApi.Host` project is the startup project and run the application which will open a Swagger UI: + +{{ else # Tiered == "No" }} + +Ensure that the `.HttpApi.Host` project is the startup project and run the application which will open a Swagger UI: + +> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. + +{{ end # Tiered }} + +![swagger-ui](images/swagger-ui.png) + +You can see the application APIs and test them here. Get [more info](https://swagger.io/tools/swagger-ui/) about the Swagger UI. + +{{ end # UI }} + +{{ if UI == "Blazor" }} + +### Running the Blazor Application (Client Side) + +Ensure that the `.Blazor` project is the startup project and run the application. + +> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. + +Once the application starts, click to the **Login** link on to header, which redirects you to the authentication server to enter a username and password: + +![bookstore-login](images/bookstore-login.png) + +{{ else if UI == "NG" }} + +### Running the Angular Application (Client Side) + +Go to the `angular` folder, open a command line terminal, type the `yarn` command (we suggest to the [yarn](https://yarnpkg.com/) package manager while `npm install` will also work) + +```bash +yarn +``` + +Once all node modules are loaded, execute `yarn start` (or `npm start`) command: + +```bash +yarn start +``` + +It may take a longer time for the first build. Once it finishes, it opens the Angular UI in your default browser with the [localhost:4200](http://localhost:4200/) address. + +![bookstore-login](images/bookstore-login.png) + +{{ end }} + +Enter **admin** as the username and **1q2w3E*** as the password to login to the application. The application is up and running. You can start developing your application based on this startup template. + +## Mobile Development + +If you want to include a [React Native](https://reactnative.dev/) project in your solution, add `-m react-native` (or `--mobile react-native`) argument to project creation command. This is a basic React Native startup template to develop mobile applications integrated to your ABP based backends. + +See the [Getting Started with the React Native](Getting-Started-React-Native.md) document to learn how to configure and run the React Native application. + +## See Also + +* [Web Application Development Tutorial](Tutorials/Part-1.md) +* [Application Startup Template](Startup-Templates/Application.md) diff --git a/docs/en/Getting-Started-Setup-Environment.md b/docs/en/Getting-Started-Setup-Environment.md new file mode 100644 index 0000000000..39a82076eb --- /dev/null +++ b/docs/en/Getting-Started-Setup-Environment.md @@ -0,0 +1,56 @@ +# Getting Started + +````json +//[doc-params] +{ + "UI": ["MVC", "Blazor", "NG"], + "DB": ["EF", "Mongo"], + "Tiered": ["Yes", "No"] +} +```` + +> This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. For other options, please change the preference on top of this document. + +## Setup Your Development Environment + +First things first! Let's setup your development environment before creating the project. + +### Pre-Requirements + +The following tools should be installed on your development machine: + +* [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) (v16.8+) for Windows / [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/). [1](#f-editor) +* [.NET Core 5.0+](https://www.microsoft.com/net/download/dotnet-core/) +{{ if UI != "Blazor" }} +* [Node v12 or v14](https://nodejs.org/) +* [Yarn v1.20+ (not v2)](https://classic.yarnpkg.com/en/docs/install) [2](#f-yarn) or npm v6+ (already installed with Node) +{{ end }} +{{ if Tiered == "Yes" }} +* [Redis](https://redis.io/) (the startup solution uses the Redis as the [distributed cache](Caching.md)). +{{ end }} + +1 _You can use another editor instead of Visual Studio as long as it supports .NET Core and ASP.NET Core._ [↩](#a-editor) + +{{ if UI != "Blazor" }} + +2 _Yarn v2 works differently and is not supported._ [↩](#a-yarn) + +{{ end }} + +### Install the ABP CLI + +[ABP CLI](./CLI.md) is a command line interface that is used to automate some common tasks for ABP based solutions. First, you need to install the ABP CLI using the following command: + +````shell +dotnet tool install -g Volo.Abp.Cli +```` + +If you've already installed, you can update it using the following command: + +````shell +dotnet tool update -g Volo.Abp.Cli +```` + +## Next Step + +* [Creating a new solution](Getting-Started-Create-Solution.md) \ No newline at end of file diff --git a/docs/en/Getting-Started.md b/docs/en/Getting-Started.md index 1e473b266f..ddafff38e4 100644 --- a/docs/en/Getting-Started.md +++ b/docs/en/Getting-Started.md @@ -9,303 +9,12 @@ } ```` -This tutorial explains how to create a new web application using the [application startup template](Startup-Templates/Application.md). - > This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. For other options, please change the preference on top of this document. +## Contents -## Setup Your Development Environment - -First things first! Let's setup your development environment before creating the first project. - -### Pre-Requirements - -The following tools should be installed on your development machine: - -* [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) for Windows / [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/). [1](#f-editor) -* [.NET Core 3.1+](https://www.microsoft.com/net/download/dotnet-core/) - -* [Node v12 or v14](https://nodejs.org/) -* [Yarn v1.20+ (not v2)](https://classic.yarnpkg.com/en/docs/install) [2](#f-yarn) or npm v6+ (already installed with Node) -{{ if Tiered == "Yes" }} - -* [Redis](https://redis.io/) (the startup solution uses the Redis as the [distributed cache](Caching.md)). - -{{ end }} - -1 _You can use another editor instead of Visual Studio as long as it supports .NET Core and ASP.NET Core._ [↩](#a-editor) - -2 _Yarn v2 works differently and is not supported._ [↩](#a-yarn) - -### Install the ABP CLI - -[ABP CLI](./CLI.md) is a command line interface that is used to automate some common tasks for ABP based solutions. - -> ABP CLI is a free & open source tool for the ABP framework. - -First, you need to install the ABP CLI using the following command: - -````shell -dotnet tool install -g Volo.Abp.Cli -```` - -If you've already installed, you can update it using the following command: - -````shell -dotnet tool update -g Volo.Abp.Cli -```` - -## Create a New Project - -Use the `new` command of the ABP CLI to create a new project: - -````shell -abp new Acme.BookStore{{if UI == "NG"}} -u angular{{else if UI == "Blazor"}} -u blazor{{end}}{{if DB == "Mongo"}} -d mongodb{{end}}{{if Tiered == "Yes"}}{{if UI == "MVC"}} --tiered{{else}} --separate-identity-server{{end}}{{end}} -```` - -> You can use different level of namespaces; e.g. BookStore, Acme.BookStore or Acme.Retail.BookStore. - -> Alternatively, you can select the "Direct Download" tab from the [ABP Framework web site](https://abp.io/get-started) to create a new solution. - -{{ if Tiered == "Yes" }} - -{{ if UI == "MVC" }} - -* `--tiered` argument is used to create N-tiered solution where authentication server, UI and API layers are physically separated. - -{{ else }} - -* `--separate-identity-server` argument is used to separate the identity server application from the API host application. If not specified, you will have a single endpoint on the server. - -{{ end }} - -{{ end }} - -### ABP CLI Commands & Options - -[ABP CLI document](./CLI.md) covers all of the available commands and options for the ABP CLI. This document uses the [application startup template](Startup-Templates/Application.md) to create a new web application. See the [ABP Startup Templates](Startup-Templates/Index.md) document for other templates. - -### The Solution Structure - -The solution has a layered structure (based on the [Domain Driven Design](Domain-Driven-Design.md)) and contains unit & integration test projects. See the [application template document](Startup-Templates/Application.md) to understand the solution structure in details. - -{{ if DB == "Mongo" }} - -#### MongoDB Transactions - -The [startup template](Startup-templates/Index.md) **disables** transactions in the `.MongoDB` project by default. If your MongoDB server supports transactions, you can enable the it in the *YourProjectMongoDbModule* class: - - ```csharp - Configure(options => - { - options.TransactionBehavior = UnitOfWorkTransactionBehavior.Auto; - }); - ``` - -> Or you can delete this code since this is already the default behavior. - -{{ end }} - -## Create the Database - -### Connection String - -Check the **connection string** in the `appsettings.json` file under the {{if Tiered == "Yes"}}`.IdentityServer` and `.HttpApi.Host` projects{{else}}{{if UI=="MVC"}}`.Web` project{{else}}`.HttpApi.Host` project{{end}}{{end}} - -{{ if DB == "EF" }} - -````json -"ConnectionStrings": { - "Default": "Server=localhost;Database=BookStore;Trusted_Connection=True" -} -```` - -The solution is configured to use **Entity Framework Core** with **MS SQL Server** by default. EF Core supports [various](https://docs.microsoft.com/en-us/ef/core/providers/) database providers, so you can use any supported DBMS. See [the Entity Framework integration document](Entity-Framework-Core.md) to learn how to [switch to another DBMS](Entity-Framework-Core-Other-DBMS.md). - -### Apply the Migrations - -The solution uses the [Entity Framework Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli). So, you need to apply migrations to create the database. There are two ways of applying the database migrations. - -#### Apply Migrations Using the DbMigrator - -The solution comes with a `.DbMigrator` console application which applies migrations and also **seeds the initial data**. It is useful on **development** as well as on **production** environment. - -> `.DbMigrator` project has its own `appsettings.json`. So, if you have changed the connection string above, you should also change this one. - -Right click to the `.DbMigrator` project and select **Set as StartUp Project** - -![set-as-startup-project](images/set-as-startup-project.png) - - Hit F5 (or Ctrl+F5) to run the application. It will have an output like shown below: - - ![db-migrator-output](images/db-migrator-output.png) - -> Initial [seed data](Data-Seeding.md) creates the `admin` user in the database (with the password is `1q2w3E*`) which is then used to login to the application. So, you need to use `.DbMigrator` at least once for a new database. - -#### Using EF Core Update-Database Command - -Ef Core has `Update-Database` command which creates database if necessary and applies pending migrations. - -{{ if UI == "MVC" }} - -Right click to the {{if Tiered == "Yes"}}`.IdentityServer`{{else}}`.Web`{{end}} project and select **Set as StartUp project**: - -{{ else if UI != "MVC" }} - -Right click to the `.HttpApi.Host` project and select **Set as StartUp Project**: - -{{ end }} - -![set-as-startup-project](images/set-as-startup-project.png) - -Open the **Package Manager Console**, select `.EntityFrameworkCore.DbMigrations` project as the **Default Project** and run the `Update-Database` command: - -![package-manager-console-update-database](images/package-manager-console-update-database.png) - -This will create a new database based on the configured connection string. - -> **Using the `.DbMigrator` tool is the suggested way**, because it also seeds the initial data to be able to properly run the web application. -> -> If you just use the `Update-Database` command, you will have an empty database, so you can not login to the application since there is no initial admin user in the database. You can use the `Update-Database` command in development time when you don't need to seed the database. However, using the `.DbMigrator` application is easier and you can always use it to migrate the schema and seed the database. - -{{ else if DB == "Mongo" }} - -````json -"ConnectionStrings": { - "Default": "mongodb://localhost:27017/BookStore" -} -```` - -The solution is configured to use **MongoDB** in your local computer, so you need to have a MongoDB server instance up and running or change the connection string to another MongoDB server. - -### Seed Initial Data - -The solution comes with a `.DbMigrator` console application which **seeds the initial data**. It is useful on **development** as well as on **production** environment. - -> `.DbMigrator` project has its own `appsettings.json`. So, if you have changed the connection string above, you should also change this one. - -Right click to the `.DbMigrator` project and select **Set as StartUp Project** - -![set-as-startup-project](images/set-as-startup-project.png) - - Hit F5 (or Ctrl+F5) to run the application. It will have an output like shown below: - - ![db-migrator-output](images/db-migrator-output.png) - -> Initial [seed data](Data-Seeding.md) creates the `admin` user in the database (with the password is `1q2w3E*`) which is then used to login to the application. So, you need to use `.DbMigrator` at least once for a new database. - -{{ end }} - -## Run the Application - -{{ if UI == "MVC" }} - -{{ if Tiered == "Yes" }} - -1. Ensure that the `.IdentityServer` project is the startup project. Run this application that will open a **login** page in your browser. - -> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. - -You can login, but you cannot enter to the main application here. This is **just the authentication server**. - -2. Ensure that the `.HttpApi.Host` project is the startup project and run the application which will open a **Swagger UI** in your browser. - -![swagger-ui](images/swagger-ui.png) - -This is the HTTP API that is used by the web application. - -3. Lastly, ensure that the `.Web` project is the startup project and run the application which will open a **welcome** page in your browser - -![mvc-tiered-app-home](images/bookstore-home.png) - -Click to the **login** button which will redirect you to the *authentication server* to login to the application: - -![bookstore-login](images/bookstore-login.png) - -{{ else # Tiered != "Yes" }} - -Ensure that the `.Web` project is the startup project. Run the application which will open the **login** page in your browser: - -> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. - -![bookstore-login](images/bookstore-login.png) - -{{ end # Tiered }} - -{{ else # UI != "MVC" }} - -### Running the HTTP API Host (Server Side) - -{{ if Tiered == "Yes" }} - -Ensure that the `.IdentityServer` project is the startup project. Run the application which will open a **login** page in your browser. - -> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. - -You can login, but you cannot enter to the main application here. This is just the authentication server. - -Ensure that the `.HttpApi.Host` project is the startup project and run the application which will open a Swagger UI: - -{{ else # Tiered == "No" }} - -Ensure that the `.HttpApi.Host` project is the startup project and run the application which will open a Swagger UI: - -> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. - -{{ end # Tiered }} - -![swagger-ui](images/swagger-ui.png) - -You can see the application APIs and test them here. Get [more info](https://swagger.io/tools/swagger-ui/) about the Swagger UI. - -> ##### Authorization for the Swagger UI -> -> Most of the HTTP APIs require authentication & authorization. If you want to test authorized APIs, manually go to the `/Account/Login` page, enter `admin` as the username and `1q2w3E*` as the password to login to the application. Then you will be able to execute authorized APIs too. - -{{ end # UI }} - -{{ if UI == "Blazor" }} - -### Running the Blazor Application (Client Side) - -Ensure that the `.Blazor` project is the startup project and run the application. - -> Use Ctrl+F5 in Visual Studio (instead of F5) to run the application without debugging. If you don't have a debug purpose, this will be faster. - -Once the application starts, click to the **Login** link on to header, which redirects you to the authentication server to enter a username and password: - -![bookstore-login](images/bookstore-login.png) - -{{ else if UI == "NG" }} - -### Running the Angular Application (Client Side) - -Go to the `angular` folder, open a command line terminal, type the `yarn` command (we suggest to the [yarn](https://yarnpkg.com/) package manager while `npm install` will also work) - -```bash -yarn -``` - -Once all node modules are loaded, execute `yarn start` (or `npm start`) command: - -```bash -yarn start -``` - -It may take a longer time for the first build. Once it finishes, it opens the Angular UI in your default browser with the [localhost:4200](http://localhost:4200/) address. - -![bookstore-login](images/bookstore-login.png) - -{{ end }} - -Enter **admin** as the username and **1q2w3E*** as the password to login to the application. The application is up and running. You can start developing your application based on this startup template. - -## Mobile Development - -If you want to include a [React Native](https://reactnative.dev/) project in your solution, add `-m react-native` (or `--mobile react-native`) argument to project creation command. This is a basic React Native startup template to develop mobile applications integrated to your ABP based backends. - -See the [Getting Started with the React Native](Getting-Started-React-Native.md) document to learn how to configure and run the React Native application. - -## Next +This tutorial explains how to **create and run** a new web application using the ABP Framework. Follow the steps below; -* [Web Application Development Tutorial](Tutorials/Part-1.md) +1. [Setup your development environment](Getting-Started-Setup-Environment) +2. [Creating a new solution](Getting-Started-Create-Solution.md) +3. [Running the solution](Getting-Started-Running-Solution.md) \ No newline at end of file diff --git a/docs/en/Index.md b/docs/en/Index.md index 949c04eb24..95052add38 100644 --- a/docs/en/Index.md +++ b/docs/en/Index.md @@ -1,31 +1,73 @@ # ABP Documentation -ABP is an **open source application framework** focused on **ASP.NET Core** based **web application development**. It also supports developing other type of applications. - -Explore the navigation menu to deep dive in the documentation. +ABP Framework is a complete **infrastructure** based on the **ASP.NET Core** to create **modern web applications** and **APIs** by following the software development **best practices** and the **latest technologies**. ## Getting Started -The easiest way to start a new web application with the ABP Framework is to use the [getting started](Getting-Started.md) guide. +* [Getting Started Guide](Getting-Started.md) is the easiest way to start a new web application with the ABP Framework. +* [Web Application Development Tutorial](Tutorials/Part-1.md) is a complete tutorial to develop a full stack web application. -## Tutorials / Articles +### UI Framework Options -### Web Application Development + -[Web application development tutorial](Tutorials/Part-1.md) is a complete tutorial to develop a full stack application using the ABP Framework. +### Database Provider Options -### ABP Community Articles + -See also the [ABP Community](https://community.abp.io/) articles. +## Exploring the Documentation -## Samples +ABP has a **comprehensive documentation** that not only explains the ABP Framework, but also includes **guides** and **samples** to help you on creating a **maintainable solution** by introducing and discussing common **software development principle and best practices**. -See the [sample projects](Samples/Index.md) built with the ABP Framework. +### Architecture + +ABP offers a complete, modular and layered software architecture based on [Domain Driven Design](Domain-Driven-Design.md) principles and patterns. It also provides the necessary infrastructure to implement this architecture. + +* See the [Modularity](Module-Development-Basics.md) document to understand the module system. +* [Implementing Domain Driven Design](Domain-Driven-Design-Implementation-Guide.md) document is an ultimate guide for who want to understand and implement the DDD. +* [Microservice Architecture](Microservice-Architecture.md) document explains how ABP helps to create a microservice solution. + +### Infrastructure + +There are a lot of features provided by the ABP Framework to achieve real world scenarios easier, like [Event Bus](Event-Bus.md), [Background Job System](Background-Jobs.md), [Audit Logging](Audit-Logging.md), [BLOB Storing](Blob-Storing.md), [Data Seeding](Data-Seeding.md), [Data Filtering](Data-Filtering.md). + +### Cross Cutting Concerns + +ABP also simplifies (and even automates wherever possible) cross cutting concerns and common non-functional requirements like [Exception Handling](Exception-Handling.md), [Validation](Validation.md), [Authorization](Authorization.md), [Localization](Localization.md), [Caching](Caching.md), [Dependency Injection](Dependency-Injection.md), [Setting Management](Settings.md), etc. + +### Application Modules + +Application Modules provides pre-built application functionalities; + +* [**Account**](Modules/Account.md): Provides UI for the account management and allows user to login/register to the application. +* **[Identity](Modules/Identity.md)**: Manages organization units, roles, users and their permissions, based on the Microsoft Identity library. +* [**IdentityServer**](Modules/IdentityServer.md): Integrates to IdentityServer4. +* [**Tenant Management**](Modules/Tenant-Management.md): Manages tenants for a [multi-tenant](Multi-Tenancy.md) (SaaS) application. -## Source Code +See the [Application Modules](Modules/Index.md) document for all pre-built modules. + +### Startup Templates + +The [Startup templates](Startup-Templates/Index.md) are pre-built Visual Studio solution templates. You can create your own solution based on these templates to **immediately start your development**. + +## ABP Community + +### The Source Code ABP is hosted on GitHub. See [the source code](https://github.com/abpframework). -## Want to Contribute? +### ABP Community Web Site + +The [ABP Community](https://community.abp.io/) is a website to publish articles and share knowledge about the ABP Framework. You can also create content for the community! + +### Blog + +Follow the [ABP Blog](https://blog.abp.io/) to learn the latest happenings in the ABP Framework. + +### Samples + +See the [sample projects](Samples/Index.md) built with the ABP Framework. + +### Want to Contribute? ABP is a community-driven open source project. See [the contribution guide](Contribution/Index.md) if you want to be a part of this project. diff --git a/docs/en/Localization.md b/docs/en/Localization.md index a33dff1779..089567422c 100644 --- a/docs/en/Localization.md +++ b/docs/en/Localization.md @@ -162,8 +162,8 @@ Getting the localized text is pretty standard. Just inject the `IStringLocalizer` service and use it like shown below: -````C# -public class MyService +````csharp +public class MyService : ITransientDependency { private readonly IStringLocalizer _localizer; diff --git a/docs/en/Migration-Guides/Abp-4_0-Angular.md b/docs/en/Migration-Guides/Abp-4_0-Angular.md new file mode 100644 index 0000000000..6095a0f447 --- /dev/null +++ b/docs/en/Migration-Guides/Abp-4_0-Angular.md @@ -0,0 +1,121 @@ +# Angular UI 3.3 to 4.0 Migration Guide + +## Angular v11 + +The new ABP Angular UI is based on Angular v11 and TypeScript v4. The difference between v10 and v11 is non-breaking so you do not have to update right away but it is recommended. Nevertheless, ABP modules will keep working with Angular v10. Therefore, if your project is Angular v10, you do not need to update to Angular 11. The update is usually very easy though. + +You can read more about Angular v11 [here](https://blog.angular.io/version-11-of-angular-now-available-74721b7952f7) + +## **Breaking Changes** + +### **Localization** + +Prior to ABP 4.x, we'd handled what locale files of Angular should be created to load them lazily. However, this made it impossible to add new locale files (to be lazily loaded) for our users. With ABP 4.x, we enabled an option to pass a function to `CoreModule`. + +The quickest solution is as follows: + +```typescript +// app.module.ts + +import { registerLocale } from '@abp/ng.core/locale'; +// or +// import { registerLocale } from '@volo/abp.ng.language-management/locale'; +// if you have commercial license + + +@NgModule({ +imports: [ + // ... + CoreModule.forRoot({ + // ...other options, + registerLocaleFn: registerLocale() + }), + //... +] +export class AppModule {} +``` + +You can find the related issue [here](https://github.com/abpframework/abp/issues/6066) +Also, please refer to [the docs](https://docs.abp.io/en/abp/latest/UI/Angular/Localization#registering-a-new-locale) for more information. + +### **Removed the Angular Account Module Public UI** + +With ABP 4.x, we have retired `@abp/ng.account`, it is no longer a part of our framework. There won't be any newer versions of this package as well. Therefore, you can delete anything related to this package. +There should be a config in `app-routing.module` for path `account` and `AccountConfigModule` import in `app.module` + +However, if you are using the commercial version of this package, a.k.a `@volo/abp.ng.account`, this package will continue to exist because it contains `AccountAdminModule` which is still being maintained and developed. You only need to delete the route config from `app-routing.module` + +You can find the related issue [here](https://github.com/abpframework/abp/issues/5652) + +Angular UI is using the Authorization Code Flow to authenticate since version 3.1.0 by default. Starting from version 4.0, this is becoming the only option, because it is the recommended way of authenticating SPAs. + +If you haven't done it yet, see [this post](https://blog.abp.io/abp/ABP-Framework-v3.1-RC-Has-Been-Released) to change the authentication of your application. + +### State Management + +In the ABP Angular UI, we've been using `NGXS` for state management. However, we've decided that the Angular UI should be agnostic with regard to state management. Our users should be able to handle the state in any way they prefer. They should be able to use any library other than `NGXS` or no library at all. That's why we have created our internal store in version 3.2. It is a simple utility class that employs `BehaviorSubject` internally. + +You can examine it [here](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/utils/internal-store-utils.ts) + +With version 4.0, we will keep utilizing our `InternalStore` instead of `@ngxs/store` in our services and move away from `@ngxs/store`. We plan to remove any dependency of `NGXS` by version 5.0. + +With this in mind, we've already deprecated some services and implemented some breaking changes. + +#### Removed the `SessionState` + +Use `SessionStateService` instead of the `SessionState`. See [this issue](https://github.com/abpframework/abp/issues/5606) for details. + +#### Deprecated the `ConfigState` + +`ConfigState` is now deprecated and should not be used. + +`ConfigState` reference removed from `CoreModule`. If you want to use the `ConfigState` (not recommended), you should pass the state to `NgxsModule` as shown below: + +```typescript +//app.module.ts + +import { ConfigState } from '@abp/ng.core'; + +// ... + +imports: [ + NgxsModule.forRoot([ConfigState]), +// ... +``` + +Moving away from the global store, we create small services with a single responsibility. There are two new services available in version 4.0 which are `EnvironmentService` and `PermissionService`. + +See [the related issue](https://github.com/abpframework/abp/issues/6154) + +Please refer to the following docs for detail information and examples +- [`ConfigStateService`](../UI/Angular/Config-State-Service) +- [`EnvironmentService`](../UI/Angular/Environment#EnvironmentService) +- [`PermissionService`](../UI/Angular/Permission-Management#) + +### Deprecated Interfaces + + Some interfaces have long been marked as deprecated and now they are removed. + +- Removed replaceable components state. +- Removed legacy identity types and service. +- Removed legacy tenant management types and service. +- Removed legacy feature management types and services. +- Removed legacy permission management types and service. + +### Deprecated commercial interfaces +- Removed legacy audit logging types and services. +- Removed legacy identity types and services. +- Removed legacy language management types and services. +- Removed legacy saas types and services. + +### Identity Server [COMMERCIAL] + +With the new version of Identity Server, there happened some breaking changes in the backend (also in the database). We've implemented those in the Angular UI. +If you are just using the package `@volo/abp.ng.identity-server` as is, you will not need to do anything. +However, there are a couple of breaking changes we need to mention. + +- As we have stated above, we want to remove the dependency of `NGXS`. Thus, we have deleted all of the actions defined in `identity-server.actions`. Those actions are not needed anymore and the state is managed locally. With the actions gone, `IdentityServerStateService` became unused and got deleted as well. + +- `ApiScope` is also available as a new entity (It was part of `ApiResource` before). It provides tokens for entity prop, entity actions, toolbar, edit and create form contributors like the existing ones which are `Client`, `IdentityResource` and `ApiResource` + +- There were some deprecated interfaces within the `IdentityServer` namespace. Those are no longer being used, instead, their replacements were generated by `ABP Cli` using the `generate-proxy` command. diff --git a/docs/en/Migration-Guides/Abp-4_0-Blazor.md b/docs/en/Migration-Guides/Abp-4_0-Blazor.md new file mode 100644 index 0000000000..90a9bc2e53 --- /dev/null +++ b/docs/en/Migration-Guides/Abp-4_0-Blazor.md @@ -0,0 +1,88 @@ +# Blazor UI 3.3 to 4.0 Migration Guide + +## Startup Template Changes + +These changes are required to manually applied in your own solution. It would be easier if you create a new solution based on 4.0 with the same name of your current solution then compare the files. + +### Csproj File / Dependencies + +* Add `true` to the `PropertyGroup` section of your project (`.csproj`) file. +* Update the `Blazorise.*` packages to the latest version (to the latest RC for the ABP 4.0 preview). + +### wwwroot/index.html + +There are some changes made in the index.html file; + +* Removed JQuery & Bootstrap JavaScript dependencies +* Replaced Bootstrap and FontAwesome imports with local files instead of CDN usages. +* Re-arranged some ABP CSS file locations. +* Introduced the `abp bundle` CLI command to manage global Style/Script file imports. + +Follow the steps below to apply the changes; + +1. Add the bundle contributor class into your project (it will be slightly different based on your solution namespaces): + +````csharp +using Volo.Abp.Bundling; + +namespace MyCompanyName.MyProjectName.Blazor +{ + public class MyProjectNameBundleContributor : IBundleContributor + { + public void AddScripts(BundleContext context) + { + } + + public void AddStyles(BundleContext context) + { + context.Add("main.css"); + } + } +} +```` + +If you are using another global style/script files, add them here. + +2. Remove all the `` elements and replace with the following comment tags: + +````html + + +```` + +3. Remove all the `` elements and replace with the following comment tags: + +````html + + +```` + +4. Execute the following command in a terminal in the root folder of the Blazor project (`.csproj`) file (ensure that you're using the ABP CLI version 4.0): + +````bash +abp bundle +```` + +This will fill in the `Styles` and `Scripts` tags based on the dependencies. + +5. You can clean the `blazor-error-ui` related sections from your `main.css` file since they are not needed anymore. + +### The Root Element + +This change is optional but recommended. + +* Change `...` to `
...
` in the `wwwroot/index.html`. +* Change `builder.RootComponents.Add("app");` to `builder.RootComponents.Add("#ApplicationContainer");` in the *YourProjectBlazorModule.cs*. + +## AbpCrudPageBase Changes + +If you've derived your pages from the `AbpCrudPageBase` class, then you may need to apply the following changes; + +- `OpenEditModalAsync` method gets `EntityDto` instead of id (`Guid`) parameter. Pass `context` instead of `context.Id`. +- `DeleteEntityAsync` method doesn't display confirmation dialog anymore. You can use the new `EntityActions` component in Data Grids to show confirmation messages. You can also inject `IUiMessageService` to your page or component and call the `ConfirmAsync` explicitly. +- Added `GetListInput` as a base property that is used to filter while getting the entities from the server. + +## Others + +- Refactored namespaces for some Blazor components ([#6015](https://github.com/abpframework/abp/issues/6015)). +- Removed Async Suffix from IUiMessageService methods ([#6123](https://github.com/abpframework/abp/pull/6123)). \ No newline at end of file diff --git a/docs/en/Migration-Guides/Abp-4_0-MVC-Razor-Pages.md b/docs/en/Migration-Guides/Abp-4_0-MVC-Razor-Pages.md new file mode 100644 index 0000000000..d2fa97ec5e --- /dev/null +++ b/docs/en/Migration-Guides/Abp-4_0-MVC-Razor-Pages.md @@ -0,0 +1,6 @@ +# MVC / Razor Pages UI 3.3 to 4.0 Migration Guide + +## Use IBrandingProvider in the Volo.Abp.UI Package + +This will be a breaking change for MVC UI, but very easy to fix. `IBrandingProvider` is being moved from `Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components` to `Volo.Abp.Ui.Branding` namespace. So, just update the namespace imports. + diff --git a/docs/en/Migration-Guides/Abp-4_0.md b/docs/en/Migration-Guides/Abp-4_0.md new file mode 100644 index 0000000000..9e1bd4e816 --- /dev/null +++ b/docs/en/Migration-Guides/Abp-4_0.md @@ -0,0 +1,280 @@ +# ABP Framework 3.3 to 4.0 Migration Guide + +This document introduces the breaking changes done in the ABP Framework 4.0 and explains how to fix your 3.x based solutions while upgrading to the ABP Framework 4.0. + +> See [the blog post](https://blog.abp.io/abp/ABP.IO-Platform-v4.0-RC-Has-Been-Released-based-on-.NET-5.0) to learn what's new with the ABP Framework 4.0. This document only focuses on the breaking changes. + +## Overall + +Here, the overall list of the changes; + +* Upgraded to the .NET 5.0 [(#6118](https://github.com/abpframework/abp/issues/6118)). +* Moved from Newtonsoft.Json to System.Text.Json [(#1198](https://github.com/abpframework/abp/issues/1198)). +* Upgraded to the Identity Server 4.1.1 ([#4461](https://github.com/abpframework/abp/issues/4461)). +* Switched to `kebab-case` for conventional URLs for the auto API controller routes ([#5325](https://github.com/abpframework/abp/issues/5325)). +* Removed Retry for the Dynamic HTTP Client Proxies ([#6090](https://github.com/abpframework/abp/issues/6090)). +* Creation audit properties of the entities made read-only ([#6020](https://github.com/abpframework/abp/issues/6020)). +* Changed type of the IHasExtraProperties.ExtraProperties ([#3751](https://github.com/abpframework/abp/issues/3751)). +* Use IBrandingProvider in the Volo.Abp.UI package and remove the one in the Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared ([#5375](https://github.com/abpframework/abp/issues/5375)). +* Removed the Angular Account Module Public UI (login, register... pages) since they are not being used in the default (authorization code) flow ([#5652](https://github.com/abpframework/abp/issues/5652)). +* Removed the SessionState in the @abp/ng.core package ([#5606](https://github.com/abpframework/abp/issues/5606)). +* Made some API revisions & startup template changes for the Blazor UI. + +## Upgraded to .NET 5.0 + +ABP Framework has been moved to .NET 5.0. So, if you want to upgrade to the ABP Framework 4.0, you also need to upgrade to .NET 5.0. + +See the [Migrate from ASP.NET Core 3.1 to 5.0](https://docs.microsoft.com/en-us/aspnet/core/migration/31-to-50) document to learn how to upgrade your solution to .NET 5.0. + +## Moved to System.Text.Json + +ABP Framework 4.0 uses the System.Text.Json by default as the JSON serialization library. It, actually, using a hybrid approach: Continues to use the Newtonsoft.Json when it needs to use features not supported by the System.Text.Json. + +### Unsupported Types + +If you want to use the Newtonsoft.Json to serialize/deserialize for some specific types, you can configure the `AbpSystemTextJsonSerializerOptions` in your module's `ConfigureServices` method. + +**Example: Use Newtonsoft.Json for `MySpecialClass`** + +````csharp +Configure(options => +{ + options.UnsupportedTypes.AddIfNotContains(typeof(MySpecialClass)); +}); +```` + +### Always Use the Newtonsoft.Json + +If you want to continue to use the Newtonsoft.Json library for all the types, you can set `UseHybridSerializer` to false in the `PreConfigureServices` method of your module class: + +````csharp +PreConfigure(options => +{ + options.UseHybridSerializer = false; +}); +```` + +## Upgraded to Identity Server 4.1.1 + +ABP Framework upgrades the [IdentityServer4](https://www.nuget.org/packages/IdentityServer4) library from 3.x to 4.1.1 with the ABP Framework version 4.0. IdentityServer 4.x has a lot of changes. Some of them are **breaking changes in the data structure**. + +### Entity Changes + +Entity changes don't directly affect your application; however, it is good to know. + +#### ApiScope + +As the **most critical breaking change**; Identity Server 4.x defines the `ApiScope` as an independent aggregate root. Previously, it was the child entity of the `ApiResource`. This change requires manual operation. See the _Database Changes_ section. + +Also, added `Enabled(string)` and `Description(bool,true)` properties. + +#### ApiResource + +- Added `AllowedAccessTokenSigningAlgorithms (string)` and `ShowInDiscoveryDocument(bool, default: true)` properties + +#### Client + +- Added `RequireRequestObject ` and `AllowedIdentityTokenSigningAlgorithms ` properties. +- Changed the default value of `RequireConsent` from `true` to `false`. +- Changed the default value of `RequirePkce` from `false` to `true`. + +#### DeviceFlowCodes + +- Added `SessionId ` and `Description ` properties. + +#### PersistedGrant + +- Added `SessionId `, `Description ` and `ConsumedTime ` properties + +### Database Changes + +> Attention: **Please backup your database** before the migration! + +**If you are upgrading from 3.x, then there are some steps should be done in your database.** + +#### Database Schema Migration + +If you are using **Entity Framework Core**, you need to add a new database migration, using the `Add-Migration` command, and apply changes to the database. Please **review the migration** script and read the sections below to understand if it affects your existing data. Otherwise, you may **lose some of your configuration**, which may not be easy to remember and re-configure. + +#### Seed Code + +If you haven't customized the `IdentityServerDataSeedContributor` and haven't customized the initial data inside the `IdentityServer*` tables; + +1. Update `IdentityServerDataSeedContributor` class by comparing to [the latest code](https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs). You probably only need to add the `CreateApiScopesAsync` method and the code related to it. +2. Then you can simply clear all the **data** in these tables then execute the `DbMigrator` application to fill it with the new configuration. + +#### Migrating the Configuration Data + +If you've customized your IdentityServer configuration in the database or in the seed data, you should understand the changes and upgrade your code/data accordingly. Especially, the following changes will affect your application: + +- `IdentityServerApiScopes` table's `Enabled` field is dropped and re-created. So, you need to enable the API scopes again manually. +- `IdentityServerApiResourceScopes` table is dropped and recreated. So, you need to backup and move your current data to the new table. +- `IdentityServerIdentityResourceClaims` table is dropped and recreated. So, you need to backup and move your current data to the new table. + +You may need to perform additional steps based on how much you made custom configurations. + +### Other IdentityServer Changes + +IdentityServer has removed the [public origin option](https://github.com/IdentityServer/IdentityServer4/pull/4335). It was resolving HTTP/HTTPS conversion issues, but they decided to leave this to the developer. This is especially needed if you use a reverse proxy where your external protocol is HTTPS but internal protocol is HTTP. + +One simple solution is to add such a middleware at the begingning of your ASP.NET Core pipeline. + +```csharp +app.Use((httpContext, next) => +{ + httpContext.Request.Scheme = "https"; + return next(); +}); +``` + +> This sample is obtained from the [ASP.NET Core documentation](https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer#scenarios-and-use-cases). You can use it if you always use HTTPS in all environments. + +### Related Resources + +- https://leastprivilege.com/2020/06/19/announcing-identityserver4-v4-0/ +- https://github.com/IdentityServer/IdentityServer4/issues/4592 + +## Auto API Controller Route Changes + +The route calculation for the [Auto API Controllers](https://docs.abp.io/en/abp/latest/API/Auto-API-Controllers) is changing with the ABP Framework version 4.0 ([#5325](https://github.com/abpframework/abp/issues/5325)). Before v4.0 the route paths were **camelCase**. After version 4.0, it's changed to **kebab-case** route paths where it is possible. + +**A typical auto API before v4.0** + +![route-before-4](images/route-before-4.png) + +**camelCase route parts become kebab-case with 4.0** + +![route-4](images/route-4.png) + +### How to Fix? + +You may not take any action for the MVC & Blazor UI projects. + +For the Angular UI, this change may effect your client UI. If you have used the [ABP CLI Service Proxy Generation](../UI/Angular/Service-Proxies.md), you can run the server side and re-generate the service proxies. If you haven't used this tool, you should manually update the related URLs in your application. + +If there are other type of clients (e.g. 3rd-party companies) using your APIs, they also need to update the URLs. + +### Use the v3.x style URLs + +If it is hard to change it in your application, you can still to use the version 3.x route strategy, by following one of the approaches; + +- Set `UseV3UrlStyle` to `true` in the options of the `options.ConventionalControllers.Create(...)` method. Example: + +```csharp +options.ConventionalControllers + .Create(typeof(BookStoreApplicationModule).Assembly, opts => + { + opts.UseV3UrlStyle = true; + }); +``` + +This approach affects only the controllers for the `BookStoreApplicationModule`. + +- Set `UseV3UrlStyle` to `true` for the `AbpConventionalControllerOptions` to set it globally. Example: + +```csharp +Configure(options => +{ + options.UseV3UrlStyle = true; +}); +``` + +Setting it globally affects all the modules in a modular application. + +## Removed Retry for the Dynamic HTTP Client Proxies + +[Dynamic C# HTTP Client Proxies](../API/Dynamic-CSharp-API-Clients.md) were trying up to 3 times if a request fails using the [Polly](https://github.com/App-vNext/Polly) library. Starting from the version 4.0, this logic has been removed. If you need it, you should configure it in your own application, by configuring the `AbpHttpClientBuilderOptions` in the `PreConfigureServices` method of your module. + +**Example: Retry 3 times on failure by incremental waiting between tries** + +````csharp +public override void PreConfigureServices(ServiceConfigurationContext context) +{ + PreConfigure(options => + { + options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) => + { + clientBuilder.AddTransientHttpErrorPolicy( + policyBuilder => policyBuilder + .WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i))) + ); + }); + }); +} +```` + +This example uses the Microsoft.Extensions.Http.Polly NuGet package. + +If you create a new solution, you can find the same configuration in the `.HttpApi.Client.ConsoleTestApp` project's module class, as an example. + +## Creation Audit Properties Made Read-Only + +Removed setters from the `IHasCreationTime.CreationTime`, ` IMustHaveCreator.CreatorId` and `IMayHaveCreator.CreatorId` properties to accidently set the creation properties while updating an existing entity. + +Since the ABP Framework automatically sets these properties, you normally don't need to directly set them. If you want to set them, as a best practice, it is suggested to make it in the constructor to not provide a way to change it later. + +These properties implemented with `protected set` in the `Entity` and `AggregateRoot` base classes. That means you can still set in a derived class, if you need it. Alternatively, you can use reflection to set them (Or use `ObjectHelper.TrySetProperty` which internally uses reflection) out of the class if you have to do. + +## Changed type of the IHasExtraProperties.ExtraProperties + +`IHasExtraProperties.ExtraProperties` was a regular `Dictionary`. With the version 4.0, it is replaced with `ExtraPropertyDictionary` class which inherits the `Dictionary`. + +Most of the applications don't be affected by this change. If you've directly implemented this interface, replace the standard dictionary to the `ExtraPropertyDictionary`. + +## Other Changes + +### IdentityOptions Usage + +Previously, when you inject `IOptions`, you get a dynamically overridden options value. For example, when you get `IdentityOptions.Password.RequiredLength`, the value is being changed based on the setting (`IdentitySettingNames.Password.RequiredLength`) of the current tenant. That means `IdentityOptions` changes per tenant. However, this caused an [issue](https://github.com/abpframework/abp/issues/6318) and we [had to change](https://github.com/abpframework/abp/pull/6333) the usage. + +With the version 4.0, you need to inject `IOptions` and call the new `SetAsync` method before using it, to be able to override the options by the settings. Otherwise, you get the default (statically configured) values of the options. + +Example usage: + +````csharp +public class MyService : ITransientDependency +{ + private readonly IOptions _options; + + public MyService(IOptions options) + { + _options = options; + } + + public async Task DoItAsync() + { + await _options.SetAsync(); + + var requiredLength = _options.Value.Password.RequiredLength; + } +} +```` + +Pre-built modules already handles this. However, if you have used `IdentityOptions` directly in your code, you also need to follow this new pattern. +Please make sure that the injected `IOptions` service and the service consuming it are in the same scope of dependency injection container. + +### LDAP module full async + +In order to solve the problem of async over sync, `ILdapManager` uses async method instead of sync. And use [`ldap4net`](https://github.com/flamencist/ldap4net) to replace [`Novell.Directory.Ldap.NETStandard`](https://github.com/dsbenghe/Novell.Directory.Ldap.NETStandard) package. + +### Dynamic external login provider system + +You need to change the `WithDynamicOptions` method and pass the `Handler` class of the external login provider. +Use the `goto definition` function in Visual Studio or Rider to check `Handler` in the extension method like `AddGoogle`. + +```csharp +- WithDynamicOptions() ++ WithDynamicOptions() +```` + +## ASP.NET Core MVC / Razor Pages UI + +See the [ASP.NET Core MVC / Razor Pages UI Migration Guide](Abp-4_0-MVC-Razor-Pages.md). + +## Angular UI + +See the [Angular UI Migration Guide](Abp-4_0-Angular.md). + +## Blazor UI + +See the [Blazor UI Migration Guide](Abp-4_0-Blazor.md). diff --git a/docs/en/Migration-Guides/Index.md b/docs/en/Migration-Guides/Index.md new file mode 100644 index 0000000000..5973ee0a0d --- /dev/null +++ b/docs/en/Migration-Guides/Index.md @@ -0,0 +1,5 @@ +# ABP Framework Migration Guides + +* [3.3.x to 4.0 Migration Guide](Abp-4_0.md) +* [2.9.x to 3.0 Migration Guide](../UI/Angular/Migration-Guide-v3.md) + diff --git a/docs/en/Migration-Guides/images/route-4.png b/docs/en/Migration-Guides/images/route-4.png new file mode 100644 index 0000000000..0d57a57f3e Binary files /dev/null and b/docs/en/Migration-Guides/images/route-4.png differ diff --git a/docs/en/Migration-Guides/images/route-before-4.png b/docs/en/Migration-Guides/images/route-before-4.png new file mode 100644 index 0000000000..48d87c60c0 Binary files /dev/null and b/docs/en/Migration-Guides/images/route-before-4.png differ diff --git a/docs/en/Module-Entity-Extensions.md b/docs/en/Module-Entity-Extensions.md index 61a7093dc5..042c10b815 100644 --- a/docs/en/Module-Entity-Extensions.md +++ b/docs/en/Module-Entity-Extensions.md @@ -1,3 +1,393 @@ # Module Entity Extensions -See https://docs.abp.io/en/commercial/latest/guides/module-entity-extensions (it will be moved here soon). \ No newline at end of file +## Introduction + +Module entity extension system is a **high level** extension system that allows you to **define new properties** for existing entities of the depended modules. It automatically **adds properties to the entity, database, HTTP API and the user interface** in a single point. + +> The module must be developed the *Module Entity Extensions* system in mind. All the **official modules** supports this system wherever possible. + +## Quick Example + +Open the *YourProjectNameModuleExtensionConfigurator* class inside the `Domain.Shared` project of your solution and change the `ConfigureExtraProperties`method as shown below to add a `SocialSecurityNumber` property to the `IdentityUser` entity of the [Identity Module](Modules/Identity.md). + +````csharp +public static void ConfigureExtraProperties() +{ + OneTimeRunner.Run(() => + { + ObjectExtensionManager.Instance.Modules() + .ConfigureIdentity(identity => + { + identity.ConfigureUser(user => + { + user.AddOrUpdateProperty( //property type: string + "SocialSecurityNumber", //property name + property => + { + //validation rules + property.Attributes.Add(new RequiredAttribute()); + property.Attributes.Add( + new StringLengthAttribute(64) { + MinimumLength = 4 + } + ); + + //...other configurations for this property + } + ); + }); + }); + }); +} +```` + +>This method is called inside the `YourProjectNameDomainSharedModule` at the beginning of the application. `OneTimeRunner` is a utility class that guarantees to execute this code only one time per application, since multiple calls are unnecessary. + +* `ObjectExtensionManager.Instance.Modules()` is the starting point to configure a module. `ConfigureIdentity(...)` method is used to configure the entities of the Identity Module. +* `identity.ConfigureUser(...)` is used to configure the user entity of the identity module. Not all entities are designed to be extensible (since it is not needed). Use the intellisense to discover the extensible modules and entities. +* `user.AddOrUpdateProperty(...)` is used to add a new property to the user entity with the `string` type (`AddOrUpdateProperty` method can be called multiple times for the same property of the same entity. Each call can configure the options of the same property, but only one property is added to the entity with the same property name). You can call this method with different property names to add more properties. +* `SocialSecurityNumber` is the name of the new property. +* `AddOrUpdateProperty` gets a second argument (the `property =>` lambda expression) to configure additional options for the new property. + * We can add data annotation attributes like shown here, just like adding a data annotation attribute to a class property. + +#### Create & Update Forms + +Once you define a property, it appears in the create and update forms of the related entity: + +![add-new-property-to-user-form](images/add-new-property-to-user-form.png) + +`SocialSecurityNumber` field comes into the form. Next sections will explain the localization and the validation for this new property. + +### Data Table + +New properties also appear in the data table of the related page: + +![add-new-property-to-user-form](images/add-new-property-to-user-table.png) + +`SocialSecurityNumber` column comes into the table. Next sections will explain the option to hide this column from the data table. + +## Property Options + +There are some options that you can configure while defining a new property. + +### Display Name + +You probably want to set a different (human readable) display name for the property that is shown on the user interface. + +#### Don't Want to Localize? + +If your application is not localized, you can directly set the `DisplayName` for the property to a `FixedLocalizableString` object. Example: + +````csharp +property => +{ + property.DisplayName = new FixedLocalizableString("Social security no"); +} +```` + +#### Localizing the Display Name + +If you want to localize the display name, you have two options. + +##### Localize by Convention + +Instead of setting the `property.DisplayName`, you can directly open your localization file (like `en.json`) and add the following entry to the `texts` section: + +````json +"SocialSecurityNumber": "Social security no" +```` + +Define the same `SocialSecurityNumber` key (the property name you've defined before) in your localization file for each language you support. That's all! + +In some cases, the localization key may conflict with other keys in your localization files. In such cases, you can use the `DisplayName:` prefix for display names in the localization file (`DisplayName:SocialSecurityNumber` as the localization key for this example). Extension system looks for prefixed version first, then fallbacks to the non prefixed name (it then fallbacks to the property name if you haven't localized it). + +> This approach is recommended since it is simple and suitable for most scenarios. + +##### Localize using the `DisplayName` Property + +If you want to specify the localization key or the localization resource, you can still set the `DisplayName` option: + +````csharp +property => +{ + property.DisplayName = + LocalizableString.Create( + "UserSocialSecurityNumberDisplayName" + ); +} +```` + +* `MyProjectNameResource` is the localization resource and `UserSocialSecurityNumberDisplayName` is the localization key in the localization resource. + +> See [the localization document](Localization.md) if you want to learn more about the localization system. + +#### Default Value + +A default value is automatically set for the new property, which is the natural default value for the property type, like `null` for `string`, `false` for `bool` or `0` for `int`. + +There are two ways to override the default value: + +##### DefaultValue Option + +`DefaultValue` option can be set to any value: + +````csharp +property => +{ + property.DefaultValue = 42; +} +```` + +##### DefaultValueFactory Options + +`DefaultValueFactory` can be set to a function that returns the default value: + +````csharp +property => +{ + property.DefaultValueFactory = () => DateTime.Now; +} +```` + +`options.DefaultValueFactory` has a higher priority than the `options.DefaultValue` . + +> Tip: Use `DefaultValueFactory` option only if the default value may change over the time (like `DateTime.Now` in this example). If it is a constant value, then use the `DefaultValue` option. + +### Validation + +Entity extension system allows you to define validation for extension properties in a few ways. + +#### Data Annotation Attributes + +`Attributes` is a list of attributes associated to this property. The example code below adds two [data annotation validation attributes](https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation) to the property: + +````csharp +property => +{ + property.Attributes.Add(new RequiredAttribute()); + property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4}); +} +```` + +When you run the application, you see that the validation works out of the box: + +![add-new-propert-to-user-form](images/add-new-property-to-user-form-validation-error.png) + +Since we've added the `RequiredAttribute`, it doesn't allow to left it blank. The validation system works; + +* On the user interface (with automatic localization). +* On the HTTP API. Even if you directly perform an HTTP request, you get validation errors with a proper HTTP status code. +* On the `SetProperty(...)` method on the entity (see [the document](Entities.md) if you wonder what is the `SetProperty()` method). + +So, it automatically makes a full stack validation. + +> See the [ASP.NET Core MVC Validation document](https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation) to learn more about the attribute based validation. + +##### Default Validation Attributes + +There are some attributes **automatically added** when you create certain type of properties; + +* `RequiredAttribute` is added for **non nullable** primitive property types (e.g. `int`, `bool`, `DateTime`...) and `enum` types. If you want to allow nulls, make the property nullable (e.g. `int?`). +* `EnumDataTypeAttribute` is added for **enum types**, to prevent to set invalid enum values. + +Use `property.Attributes.Clear();` if you don't want these attributes. + +#### Validation Actions + +Validation actions allows you to execute a custom code to perform the validation. The example below checks if the `SocialSecurityNumber` starts with `B` and adds a validation error if so: + +````csharp +property => +{ + property.Attributes.Add(new RequiredAttribute()); + property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4}); + + property.Validators.Add(context => + { + if (((string) context.Value).StartsWith("B")) + { + context.ValidationErrors.Add( + new ValidationResult( + "Social security number can not start with the letter 'B', sorry!", + new[] {"extraProperties.SocialSecurityNumber"} + ) + ); + } + }); + +} +```` + +Using a `RegularExpressionAttribute` might be better in this case, but this is just an example. Anyway, if you enter a value starts with the letter `B` you get the following error **while saving the form**: + +![add-new-propert-to-user-form](images/add-new-property-to-user-form-validation-error-custom.png) + +##### The Context Object + +The `context` object has useful properties that can be used in your custom validation action. For example, you can use the `context.ServiceProvider` to resolve services from the [dependency injection system](Dependency-Injection.md). The example below gets the localizer and adds a localized error message: + +````csharp +if (((string) context.Value).StartsWith("B")) +{ + var localizer = context.ServiceProvider + .GetRequiredService>(); + + context.ValidationErrors.Add( + new ValidationResult( + localizer["SocialSecurityNumberCanNotStartWithB"], + new[] {"extraProperties.SocialSecurityNumber"} + ) + ); +} +```` + +>`context.ServiceProvider` is nullable! It can be `null` only if you use the `SetProperty(...)` method on the object. Because DI system is not available on this time. While this is a rare case, you should perform a fallback logic when `context.ServiceProvider` is `null`. For this example, you would add a non-localized error message. This is not a problem since setting an invalid value to a property generally is a programmer mistake and you mostly don't need to localization in this case. In any way, you would not be able to use localization even in a regular property setter. But, if you are serious about localization, you can throw a business exception (see the [exception handling document](https://docs.abp.io/en/abp/latest/Exception-Handling) to learn how to localize a business exception). + +### UI Visibility + +When you define a property, it appears on the data table, create and edit forms on the related UI page. However, you can control each one individually. Example: + +````csharp +property => +{ + property.UI.OnTable.IsVisible = false; + //...other configurations +} +```` + +Use `property.UI.OnCreateForm` and `property.UI.OnEditForm` to control forms too. If a property is required, but not added to the create form, you definitely get a validation exception, so use this option carefully. But a required property may not be in the edit form if that's your requirement. + +### HTTP API Availability + +Even if you disable a property on UI, it can be still available through the HTTP API. By default, a property is available on all APIs. + +Use the `property.Api` options to make a property unavailable in some API endpoints. + +````csharp +property => +{ + property.Api.OnUpdate.IsAvailable = false; +} +```` + +In this example, Update HTTP API will not allow to set a new value to this property. In this case, you also want to disable this property on the edit form: + +````csharp +property => +{ + property.Api.OnUpdate.IsAvailable = false; + property.UI.OnEditForm.IsVisible = false; +} +```` + +In addition to the `property.Api.OnUpdate`, you can set `property.Api.OnCreate` and `property.Api.OnGet` for a fine control the API endpoint. + +## Special Types + +### Enum + +Module extension system naturally supports the `enum` types. + +An example enum type: + +````csharp +public enum UserType +{ + Regular, + Moderator, + SuperUser +} +```` + +You can add enum properties just like others: + +````csharp +user.AddOrUpdateProperty("Type"); +```` + +An enum properties is shown as combobox (select) in the create/edit forms: + +![add-new-property-enum](images/add-new-property-enum.png) + +#### Localization + +Enum member name is shown on the table and forms by default. If you want to localize it, just create a new entry on your [localization](https://docs.abp.io/en/abp/latest/Localization) file: + +````json +"UserType.SuperUser": "Super user" +```` + +One of the following names can be used as the localization key: + +* `Enum:UserType.SuperUser` +* `UserType.SuperUser` +* `SuperUser` + +Localization system searches for the key with the given order. Localized text are used on the table and the create/edit forms. + +## Database Mapping + +For relational databases, all extension property values are stored in a single field in the table: + +![add-new-propert-to-user-database-extra-properties](images/add-new-propert-to-user-database-extra-properties.png) + +`ExtraProperties` field stores the properties as a JSON object. While that's fine for some scenarios, you may want to create a dedicated field for your new property. Fortunately, it is very easy to configure. + +If you are using the Entity Framework Core database provider, you can configure the database mapping as shown below: + +````csharp +ObjectExtensionManager.Instance + .MapEfCoreProperty( + "SocialSecurityNumber", + (entityBuilder, propertyBuilder) => + { + propertyBuilder.HasMaxLength(64); + } + ); +```` + +Write this inside the `YourProjectNameEfCoreEntityExtensionMappings` class in your `.EntityFrameworkCore` project. Then you need to use the standard `Add-Migration` and `Update-Database` commands to create a new database migration and apply the change to your database. + +Add-Migration create a new migration as shown below: + +````csharp +public partial class Added_SocialSecurityNumber_To_IdentityUser : Migration +{ + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "SocialSecurityNumber", + table: "AbpUsers", + maxLength: 128, + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "SocialSecurityNumber", + table: "AbpUsers"); + } +} +```` + +Once you update your database, you will see that the `AbpUsers` table has the new property as a standard table field: + +![add-new-propert-to-user-database-extra-properties](images/add-new-propert-to-user-database-field.png) + +> If you first created a property without a database table field, then you later needed to move this property to a database table field, it is suggested to execute an SQL command in your migration to copy the old values to the new field. +> +> However, if you don't make it, the ABP Framework seamlessly manages it. It uses the new database field, but fallbacks to the `ExtraProperties` field if it is null. When you save the entity, it moves the value to the new field. + +See the [Extending Entities](Customizing-Application-Modules-Extending-Entities.md) document for more. + +## More + +See the [Customizing the Modules](Customizing-Application-Modules-Guide.md) guide for an overall index for all the extensibility options. + +Here, a few things you can do: + +* You can create a second entity that maps to the same database table with the extra property as a standard class property (if you've defined the EF Core mapping). For the example above, you can add a `public string SocialSecurityNumber {get; set;}` property to the `AppUser` entity in your application, since the `AppUser` entity is mapped to the same `AbpUser` table. Do this only if you need it, since it brings more complexity to your application. +* You can override a domain or application service to perform custom logics with your new property. +* You can low level control how to add/render a field in the data table on the UI. + diff --git a/docs/en/Modules/Account.md b/docs/en/Modules/Account.md index 6901b38f59..94cdb7af95 100644 --- a/docs/en/Modules/Account.md +++ b/docs/en/Modules/Account.md @@ -1,3 +1,38 @@ # Account Module -TODO \ No newline at end of file +This module provides necessary UI pages/components to make the user login and register to the application. + +> This document is incomplete. + +## Social/External Logins + +The [Account Module](../Modules/Account.md) has already configured to handle social or external logins out of the box. You can follow the ASP.NET Core documentation to add a social/external login provider to your application. + +### Example: Facebook Authentication + +Follow the [ASP.NET Core Facebook integration document](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins) to support the Facebook login for your application. + +#### Add the NuGet Package + +Add the [Microsoft.AspNetCore.Authentication.Facebook](https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.Facebook) package to your project. Based on your architecture, this can be `.Web`, `.IdentityServer` (for tiered setup) or `.Host` project. + +#### Configure the Provider + +Use the `.AddFacebook(...)` extension method in the `ConfigureServices` method of your [module](../Module-Development-Basics.md), to configure the client: + +````csharp +context.Services.AddAuthentication() + .AddFacebook(facebook => + { + facebook.AppId = "..."; + facebook.AppSecret = "..."; + facebook.Scope.Add("email"); + facebook.Scope.Add("public_profile"); + }); +```` + +> It would be a better practice to use the `appsettings.json` or the ASP.NET Core User Secrets system to store your credentials, instead of a hard-coded value like that. Follow the [Microsoft's document](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins) to learn the user secrets usage. + +### Other UI Types + +Beginning from the v3.1, the [Angular UI](../UI/Angular/Quick-Start.md) uses authorization code flow (as a best practice) to authenticate the user by redirecting to the MVC UI login page. So, even if you are using the Angular UI, social/external login integration is same as explained above and it will work out of the box. As similar, The [Blazor UI](../UI/Blazor/Overall.md) also uses the MVC UI to logic. \ No newline at end of file diff --git a/docs/en/Modules/Client-Simulation.md b/docs/en/Modules/Client-Simulation.md new file mode 100644 index 0000000000..bc5d38e814 --- /dev/null +++ b/docs/en/Modules/Client-Simulation.md @@ -0,0 +1,3 @@ +# Client Simulation Module + +TODO \ No newline at end of file diff --git a/docs/en/Modules/Cms-Kit.md b/docs/en/Modules/Cms-Kit.md new file mode 100644 index 0000000000..e13f1e585b --- /dev/null +++ b/docs/en/Modules/Cms-Kit.md @@ -0,0 +1,3 @@ +# CMS Kit Module + +TODO \ No newline at end of file diff --git a/docs/en/Modules/Docs.md b/docs/en/Modules/Docs.md index e788a4c0f8..5780b4b827 100644 --- a/docs/en/Modules/Docs.md +++ b/docs/en/Modules/Docs.md @@ -446,7 +446,7 @@ As an example you can see ABP Framework documentation: #### Conditional sections feature (Using Scriban) -Docs module uses [Scriban]( ) for conditionally show or hide some parts of a document. In order to use that feature, you have to create a JSON file as **Parameter document** per every language. It will contain all the key-values, as well as their display names. +Docs module uses [Scriban](https://github.com/lunet-io/scriban/tree/master/doc) for conditionally show or hide some parts of a document. In order to use that feature, you have to create a JSON file as **Parameter document** per every language. It will contain all the key-values, as well as their display names. For example, [en/docs-params.json](https://github.com/abpio/abp-commercial-docs/blob/master/en/docs-params.json): @@ -537,7 +537,7 @@ Also, **Document_Language_Code** and **Document_Version** keys are pre-defined i ------ -**IMPORTANT NOTICE**: Scriban uses "{{" and "}}" for syntax. Therefore, you must use escape blocks if you are going to use those in your document (an Angular document, for example). See [Scriban docs]( ) for more information. +**IMPORTANT NOTICE**: Scriban uses "{{" and "}}" for syntax. Therefore, you must use escape blocks if you are going to use those in your document (an Angular document, for example). See [Scriban docs](https://github.com/lunet-io/scriban/blob/master/doc/language.md#13-escape-block) for more information. ### 8- Creating the Navigation Document diff --git a/docs/en/Modules/Identity.md b/docs/en/Modules/Identity.md index b38f59c03b..8cd7bf3966 100644 --- a/docs/en/Modules/Identity.md +++ b/docs/en/Modules/Identity.md @@ -1,8 +1,8 @@ # Identity Management Module -Identity module is used to manage [organization units](Organization-Units.md), roles, users and their permissions, based on the Microsoft Identity library. +Identity module is used to manage organization units, roles, users and their permissions, based on the Microsoft Identity library. -**See [the source code](https://github.com/abpframework/abp/tree/dev/modules/identity). Documentation will come soon...** +> **See [the source code](https://github.com/abpframework/abp/tree/dev/modules/identity). Documentation will come soon...** ## Identity Security Log @@ -27,3 +27,51 @@ Configure(options => options.ApplicationName = "AbpSecurityTest"; }); ``` + +## Organization Unit Management + +Organization units (OU) is a part of **Identity Module** and can be used to **hierarchically group users and entities**. + +### OrganizationUnit Entity + +An OU is represented by the **OrganizationUnit** entity. The fundamental properties of this entity are: + +- **TenantId**: Tenant's Id of this OU. Can be null for host OUs. +- **ParentId**: Parent OU's Id. Can be null if this is a root OU. +- **Code**: A hierarchical string code that is unique for a tenant. +- **DisplayName**: Shown name of the OU. + +The OrganizationUnit entity's primary key (Id) is a **Guid** type and it derives from the [**FullAuditedAggregateRoot**](../Entities.md) class. + +#### Organization Tree + +Since an OU can have a parent, all OUs of a tenant are in a **tree** structure. There are some rules for this tree; + +- There can be more than one root (where the `ParentId` is `null`). +- There is a limit for the first-level children count of an OU (because of the fixed OU Code unit length explained below). + +#### OU Code + +OU code is automatically generated and maintained by the OrganizationUnit Manager. It's a string that looks something like this: + +"**00001.00042.00005**" + +This code can be used to easily query the database for all the children of an OU (recursively). There are some rules for this code: + +- It must be **unique** for a [tenant](../Multi-Tenancy.md). +- All the children of the same OU have codes that **start with the parent OU's code**. +- It's **fixed length** and based on the level of the OU in the tree, as shown in the sample. +- While the OU code is unique, it can be **changeable** if you move an OU. +- You must reference an OU by Id, not Code. + +### OrganizationUnit Manager + +The **OrganizationUnitManager** class can be [injected](../Dependency-Injection.md) and used to manage OUs. Common use cases are: + +- Create, Update or Delete an OU +- Move an OU in the OU tree. +- Getting information about the OU tree and its items. + +#### Multi-Tenancy + +The `OrganizationUnitManager` is designed to work for a **single tenant** at a time. It works for the **current tenant** by default. \ No newline at end of file diff --git a/docs/en/Modules/Index.md b/docs/en/Modules/Index.md index ae17c15c8a..9d0199f4c3 100644 --- a/docs/en/Modules/Index.md +++ b/docs/en/Modules/Index.md @@ -1,6 +1,6 @@ # Application Modules -ABP is a **modular application framework** which consists of dozens of **nuget packages**. It also provides a complete infrastructure to build your own application modules which may have entities, services, database integration, APIs, UI components and so on. +ABP is a **modular application framework** which consists of dozens of **NuGet & NPM packages**. It also provides a complete infrastructure to build your own application modules which may have entities, services, database integration, APIs, UI components and so on. There are **two types of modules.** They don't have any structural difference but categorized by functionality and purpose: @@ -9,24 +9,26 @@ There are **two types of modules.** They don't have any structural difference bu ## Open Source Application Modules -There are some **free and open source** application modules developed and maintained by the ABP community: +There are some **free and open source** application modules developed and maintained as a part of the ABP Framework. -* **Account**: Provides UI for the account management and allows user to login/register to the application. +* [**Account**](Account.md): Provides UI for the account management and allows user to login/register to the application. * [**Audit Logging**](Audit-Logging.md): Persists audit logs to a database. -* **Background Jobs**: Persist background jobs when using the default background job manager. -* **Blogging**: Used to create fancy blogs. ABP's [own blog](https://blog.abp.io/) already using this module. -* [**Docs**](Docs.md): Used to create technical documentation pages. ABP's [own documentation](https://docs.abp.io) already using this module. -* **Feature Management**: Used to persist and manage the [features](../Features.md). +* [**Background Jobs**](Background-Jobs.md): Persist background jobs when using the default background job manager. +* [**Blogging**](Blogging.md): Used to create fancy blogs. ABP's [own blog](https://blog.abp.io/) already using this module. +* [**Client Simulation**](Client-Simulation.md): A simple web UI to stress test HTTP APIs by simulating concurrent clients. +* [**CMS Kit**](Cms-Kit.md): A set of reusable *Content Management System* features. +* [**Docs**](Docs.md): Used to create technical documentation website. ABP's [own documentation](https://docs.abp.io) already using this module. +* [**Feature Management**](Feature-Management.md): Used to persist and manage the [features](../Features.md). * **[Identity](Identity.md)**: Manages organization units, roles, users and their permissions, based on the Microsoft Identity library. -* **IdentityServer**: Integrates to IdentityServer4. -* **Permission Management**: Used to persist permissions. +* [**IdentityServer**](IdentityServer.md): Integrates to IdentityServer4. +* [**Permission Management**](Permission-Management.md): Used to persist permissions. * **[Setting Management](Setting-Management.md)**: Used to persist and manage the [settings](../Settings.md). -* **Tenant Management**: Manages tenants for a [multi-tenant](../Multi-Tenancy.md) application. -* **Users**: Abstract users, so other modules can depend on this module instead of the Identity module. +* [**Tenant Management**](Tenant-Management.md): Manages tenants for a [multi-tenant](../Multi-Tenancy.md) application. +* [**Users**](Users.md): Abstract users, so other modules can depend on this module instead of the Identity module. * [**Virtual File Explorer**](Virtual-File-Explorer.md): Provided a simple UI to view files in [virtual file system](../Virtual-File-System.md). See [the GitHub repository](https://github.com/abpframework/abp/tree/master/modules) for source code of all modules. ## Commercial Application Modules -[ABP Commercial](https://commercial.abp.io/) license provides additional pre-built application modules on top of the ABP framework. See the [module list](https://commercial.abp.io/modules) provided by the ABP Commercial. \ No newline at end of file +[ABP Commercial](https://commercial.abp.io/) license provides **additional pre-built application modules** on top of the ABP framework. See the [module list](https://commercial.abp.io/modules) provided by the ABP Commercial. \ No newline at end of file diff --git a/docs/en/Modules/Organization-Units.md b/docs/en/Modules/Organization-Units.md deleted file mode 100644 index b27e038528..0000000000 --- a/docs/en/Modules/Organization-Units.md +++ /dev/null @@ -1,47 +0,0 @@ -# Organization Unit Management - -Organization units (OU) is a part of **Identity Module** and can be used to **hierarchically group users and entities**. - -### OrganizationUnit Entity - -An OU is represented by the **OrganizationUnit** entity. The fundamental properties of this entity are: - -- **TenantId**: Tenant's Id of this OU. Can be null for host OUs. -- **ParentId**: Parent OU's Id. Can be null if this is a root OU. -- **Code**: A hierarchical string code that is unique for a tenant. -- **DisplayName**: Shown name of the OU. - -The OrganizationUnit entity's primary key (Id) is a **Guid** type and it derives from the [**FullAuditedAggregateRoot**](../Entities.md) class. - -#### Organization Tree - -Since an OU can have a parent, all OUs of a tenant are in a **tree** structure. There are some rules for this tree; - -- There can be more than one root (where the `ParentId` is `null`). -- There is a limit for the first-level children count of an OU (because of the fixed OU Code unit length explained below). - -#### OU Code - -OU code is automatically generated and maintained by the OrganizationUnit Manager. It's a string that looks something like this: - -"**00001.00042.00005**" - -This code can be used to easily query the database for all the children of an OU (recursively). There are some rules for this code: - -- It must be **unique** for a [tenant](../Multi-Tenancy.md). -- All the children of the same OU have codes that **start with the parent OU's code**. -- It's **fixed length** and based on the level of the OU in the tree, as shown in the sample. -- While the OU code is unique, it can be **changeable** if you move an OU. -- You must reference an OU by Id, not Code. - -### OrganizationUnit Manager - -The **OrganizationUnitManager** class can be [injected](../Dependency-Injection.md) and used to manage OUs. Common use cases are: - -- Create, Update or Delete an OU -- Move an OU in the OU tree. -- Getting information about the OU tree and its items. - -#### Multi-Tenancy - -The `OrganizationUnitManager` is designed to work for a **single tenant** at a time. It works for the **current tenant** by default. diff --git a/docs/en/Modules/Users.md b/docs/en/Modules/Users.md new file mode 100644 index 0000000000..1cb0f4b701 --- /dev/null +++ b/docs/en/Modules/Users.md @@ -0,0 +1,3 @@ +# Users Module + +TODO \ No newline at end of file diff --git a/docs/en/MongoDB.md b/docs/en/MongoDB.md index 475eb94f1b..98769c13b8 100644 --- a/docs/en/MongoDB.md +++ b/docs/en/MongoDB.md @@ -40,7 +40,7 @@ public class MyDbContext : AbpMongoDbContext protected override void CreateModel(IMongoModelBuilder modelBuilder) { base.CreateModel(modelBuilder); - + //Customize the configuration for your collections. } } @@ -62,7 +62,7 @@ So, most of times you don't need to explicitly configure registration for your e protected override void CreateModel(IMongoModelBuilder modelBuilder) { base.CreateModel(modelBuilder); - + modelBuilder.Entity(b => { b.CollectionName = "MyQuestions"; //Sets the collection name @@ -88,7 +88,7 @@ If you have multiple databases in your application, you can configure the connec [ConnectionStringName("MySecondConnString")] public class MyDbContext : AbpMongoDbContext { - + } ```` @@ -202,7 +202,7 @@ You generally want to derive from the `IRepository` to inherit standard reposito Example implementation of the `IBookRepository` interface: ```csharp -public class BookRepository : +public class BookRepository : MongoDbRepository, IBookRepository { @@ -242,9 +242,9 @@ context.Services.AddMongoDbContext(options => This is especially important when you want to **override a base repository method** to customize it. For instance, you may want to override `DeleteAsync` method to delete an entity in a more efficient way: ```csharp -public override async Task DeleteAsync( - Guid id, - bool autoSave = false, +public async override Task DeleteAsync( + Guid id, + bool autoSave = false, CancellationToken cancellationToken = default) { //TODO: Custom implementation of the delete method @@ -381,4 +381,4 @@ context.Services.AddMongoDbContext(options => }); ``` -In this example, `OtherMongoDbContext` implements `IBookStoreMongoDbContext`. This feature allows you to have multiple MongoDbContext (one per module) on development, but single MongoDbContext (implements all interfaces of all MongoDbContexts) on runtime. \ No newline at end of file +In this example, `OtherMongoDbContext` implements `IBookStoreMongoDbContext`. This feature allows you to have multiple MongoDbContext (one per module) on development, but single MongoDbContext (implements all interfaces of all MongoDbContexts) on runtime. diff --git a/docs/en/Multi-Tenancy.md b/docs/en/Multi-Tenancy.md index 03b3420ada..8cdda55af2 100644 --- a/docs/en/Multi-Tenancy.md +++ b/docs/en/Multi-Tenancy.md @@ -329,6 +329,7 @@ Configure(options => `MyCustomTenantResolveContributor` must inherit from the `TenantResolveContributorBase` (or implement the `ITenantResolveContributor`) as shown below: ````csharp +using System.Threading.Tasks; using Volo.Abp.MultiTenancy; namespace MultiTenancyDemo.Web @@ -337,7 +338,7 @@ namespace MultiTenancyDemo.Web { public override string Name => "Custom"; - public override void Resolve(ITenantResolveContext context) + public override Task ResolveAsync(ITenantResolveContext context) { //TODO... } diff --git a/docs/en/PlugIn-Modules.md b/docs/en/PlugIn-Modules.md new file mode 100644 index 0000000000..1d613582ab --- /dev/null +++ b/docs/en/PlugIn-Modules.md @@ -0,0 +1,233 @@ +# Plug-In Modules + +It is possible to load [modules](Module-Development-Basics.md) as plug-ins. That means you may not reference to a module's assembly in your solution, but you can load that module in the application startup just like any other module. + +## Basic Usage + +`IServiceCollection.AddApplication()` extension method can get options to configure the plug-in sources. + +**Example: Load plugins from a folder** + +````csharp +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity.PlugIns; + +namespace MyPlugInDemo.Web +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(options => + { + options.PlugInSources.AddFolder(@"D:\Temp\MyPlugIns"); + }); + } + + public void Configure(IApplicationBuilder app) + { + app.InitializeApplication(); + } + } +} +```` + +* This is the `Startup` class of a typical ASP.NET Core application. +* `PlugInSources.AddFolder` gets a folder path and to load assemblies (typically `dll`s) in that folder. + +That's all. ABP will discover the modules in the given folder, configure and initialize them just like regular modules. + +### Plug-In Sources + +`options.PlugInSources` is actually a list of `IPlugInSource` implementations and `AddFolder` is just a shortcut for the following expression: + +````csharp +options.PlugInSources.Add(new FolderPlugInSource(@"D:\Temp\MyPlugIns")); +```` + +> `AddFolder()` only looks for the assembly file in the given folder, but not looks for the sub-folders. You can pass `SearchOption.AllDirectories` as a second parameter to explore plug-ins also from the sub-folders, recursively. + +There are two more built-in Plug-In Source implementations: + +* `PlugInSources.AddFiles()` gets a list of assembly (typically `dll`) files. This is a shortcut of using `FilePlugInSource` class. +* `PlugInSources.AddTypes()` gets a list of module class types. If you use this, you need to load the assemblies of the modules yourself, but it provides flexibility when needed. This is a shortcut of using `TypePlugInSource` class. + +If you need, you can create your own `IPlugInSource` implementation and add to the `options.PlugInSources` just like the others. + +## Example: Creating a Simple Plug-In + +Create a simple **Class Library Project** in a solution: + +![simple-plugin-library](images/simple-plugin-library.png) + +You can add ABP Framework packages you need to use in the module. At least, you should add the `Volo.Abp.Core` package to the project: + +```` +Install-Package Volo.Abp.Core +```` + +Every [module](Module-Development-Basics.md) must declare a class derived from the `AbpModule`. Here, a simple module class that resolves a service and initializes it on the application startup: + +````csharp +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; +using Volo.Abp.Modularity; + +namespace MyPlugIn +{ + public class MyPlungInModule : AbpModule + { + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var myService = context.ServiceProvider + .GetRequiredService(); + + myService.Initialize(); + } + } +} +```` + +`MyService` can be any class registered to [Dependency Injection](Dependency-Injection.md) system, as show below: + +````csharp +using Microsoft.Extensions.Logging; +using Volo.Abp.DependencyInjection; + +namespace MyPlugIn +{ + public class MyService : ITransientDependency + { + private readonly ILogger _logger; + + public MyService(ILogger logger) + { + _logger = logger; + } + + public void Initialize() + { + _logger.LogInformation("MyService has been initialized"); + } + } +} +```` + +Build the project, open the build folder, find the `MyPlugIn.dll`: + +![simple-plug-in-dll-file](images/simple-plug-in-dll-file.png) + +Copy `MyPlugIn.dll` into the plug-in folder (`D:\Temp\MyPlugIns` for this example). + +If you have configured the main application like described above (see Basic Usage section), you should see the `MyService has been initialized` log in the application startup. + +## Example: Creating a Plug-In With Razor Pages + +Creating plug-ins with views inside requires a bit more attention. + +> This example assumes you've [created a new web application](https://abp.io/get-started) using the application startup template and MVC / Razor Pages UI. + +Create a new **Class Library** project in a solution: + +![simple-razor-plugin](images/simple-razor-plugin.png) + +Edit the `.csproj` file content: + +````xml + + + + net5.0 + Library + true + + + + + + + +```` + +* Changed `Sdk` to `Microsoft.NET.Sdk.Web`. +* Added `OutputType` and `IsPackable` properties. +* Added `Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared` NuGet package. + +> Depending on [Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared) package is not required. You can reference to a more base package like [Volo.Abp.AspNetCore.Mvc](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc/). However, if you will build a UI page/component, it is suggested to reference to the [Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared) package since it is the most high-level package without depending on a particular [theme](UI/AspNetCore/Theming.md). If there is no problem to depend on a particular theme, you can directly reference to the theme's package to be able to use the theme-specific features in your plug-in. + +Then create your module class in the plug-in: + +````csharp +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Mvc.ApplicationParts; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; +using Volo.Abp.Modularity; + +namespace MyMvcUIPlugIn +{ + [DependsOn(typeof(AbpAspNetCoreMvcUiThemeSharedModule))] + public class MyMvcUIPlugInModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => + { + //Add plugin assembly + mvcBuilder.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(MyMvcUIPlugInModule).Assembly)); + + //Add views assembly + var viewDllPath = Path.Combine(Path.GetDirectoryName(typeof(MyMvcUIPlugInModule).Assembly.Location), "MyMvcUIPlugIn.Views.dll"); + var viewAssembly = new CompiledRazorAssemblyPart(Assembly.LoadFrom(viewDllPath)); + mvcBuilder.PartManager.ApplicationParts.Add(viewAssembly); + }); + } + } +} +```` + +* Depending on the `AbpAspNetCoreMvcUiThemeSharedModule` since we added the related NuGet package. +* Adding the plug-in's assembly to the `PartManager` of ASP.NET Core MVC. This is required by ASP.NET Core. Otherwise, your controllers inside the plug-in doesn't work. +* Adding the plug-in's views assembly to the `PartManager` of ASP.NET Core MVC. This is required by ASP.NET Core. Otherwise, your views inside the plug-in doesn't work. + +You can now add a razor page, like `MyPlugInPage.cshtml` inside the `Pages` folder: + +````html +@page +@model MyMvcUIPlugIn.Pages.MyPlugInPage +

Welcome to my plug-in page

+

This page is located inside a plug-in module! :)

+```` + +Now, you can build the plug-in project. It will produce the following output: + +![simple-razor-plug-in-dll-file](images/simple-razor-plug-in-dll-file.png) + +Copy the `MyMvcUIPlugIn.dll` and `MyMvcUIPlugIn.Views.dll` into the plug-in folder (`D:\Temp\MyPlugIns` for this example). + +If you have configured the main application like described above (see Basic Usage section), you should be able to visit the `/MyPlugInPage` URL when your application: + +![simple-plugin-output](images/simple-plugin-output.png) + +## Discussions + +In real world, your plug-in may have some external dependencies. Also, your application might be designed to support plug-ins. All these are your own system requirements. What ABP does is just loading modules on the application startup. What you do inside that modules is up to you. + +However, we can provide a few suggestions for some common cases. + +### Library Dependencies + +For package/dll dependencies, you can copy the related dlls to the plug-in folder. ABP automatically loads all assemblies in the folder and your plug-in will work as expected. + +> See [Microsoft's documentation](https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-with-library-dependencies) for some additional explanations for that case. + +### Database Schema + +If your module uses a relational database and [Entity Framework Core](Entity-Framework-Core.md), it will need to have its tables available in the database. There are different ways to ensure the tables have been created when an application uses the plug-in. Some examples; + +1. The Plugin may check if the database tables does exists and create the tables on the application startup or migrate them if the plug-in has been updated and requires some schema changes. You can use EF Core's migration API to do that. +2. You can improve the `DbMigrator` application to find migrations of the plug-ins and execute them. + +There may be other solutions. For example, if your DB admin doesn't allow you to change the database schema in the application code, you may need to manually send a SQL file to the database admin to apply it to the database. \ No newline at end of file diff --git a/docs/en/Repositories.md b/docs/en/Repositories.md index 0fc80984e7..5ff8372af8 100644 --- a/docs/en/Repositories.md +++ b/docs/en/Repositories.md @@ -79,6 +79,14 @@ If your entity does not have an Id primary key (it may have a composite primary > `IRepository` has a few missing methods those normally works with the `Id` property of an entity. Because of the entity has no `Id` property in that case, these methods are not available. One example is the `Get` method that gets an id and returns the entity with given id. However, you can still use `IQueryable` features to query entities by standard LINQ methods. +### Soft / Hard Delete + +`DeleteAsync` method of the repository doesn't delete the entity if the entity is a **soft-delete** entity (that implements `ISoftDelete`). Soft-delete entities are marked as "deleted" in the database. Data Filter system ensures that the soft deleted entities are not retrieved from database normally. + +If your entity is a soft-delete entity, you can use the `HardDeleteAsync` method to really delete the entity from database in case of you need it. + +See the [Data Filtering](Data-Filtering.md) documentation for more about soft-delete. + ## Custom Repositories Default generic repositories will be sufficient for most cases. However, you may need to create a custom repository class for your entity. diff --git a/docs/en/Road-Map.md b/docs/en/Road-Map.md index 8670ba080b..3a45ca1767 100644 --- a/docs/en/Road-Map.md +++ b/docs/en/Road-Map.md @@ -1,17 +1,12 @@ # ABP Framework Road Map -You can always check the milestone planning and the prioritized backlog issues on [the GitHub repository](https://github.com/abpframework/abp/milestones) for a detailed road map. - -While we will **continue to add other exciting features**, we will work on the following major items in the **middle term**: - -* **Blazor UI** for the framework and all the pre-built modules (in progress). -* **.NET 5.0**! As Microsoft has announced that the .NET 5.0 will be released in November 2020, we will prepare for this change before and move to the .NET 5.0 just after Microsoft releases it. We hope a smooth transition. - -Beside this middle term goals, there are many features in the [backlog](https://github.com/abpframework/abp/milestone/2). Here, a list of some major items in the backlog; +You can always check the milestone planning and the prioritized backlog issues on [the GitHub repository](https://github.com/abpframework/abp/milestones) for a detailed road map. Here, a list of some major items in the backlog; * [#2882](https://github.com/abpframework/abp/issues/2882) / Providing a gRPC integration infrastructure (while it is [already possible](https://github.com/abpframework/abp-samples/tree/master/GrpcDemo) to create or consume gRPC endpoints for your application, we plan to create endpoints for the [standard application modules](https://docs.abp.io/en/abp/latest/Modules/Index)) * [#236](https://github.com/abpframework/abp/issues/236) Resource based authorization system +* [#6132](https://github.com/abpframework/abp/issues/6132) A New Theme alternative to the Basic Theme * [#1754](https://github.com/abpframework/abp/issues/1754) / Multi-lingual entities +* [#497](https://github.com/abpframework/abp/issues/497) API Versioning system finalize & document * [#633](https://github.com/abpframework/abp/issues/633) / Realtime notification system * [#57](https://github.com/abpframework/abp/issues/57) / Built-in CQRS infrastructure * [#336](https://github.com/abpframework/abp/issues/336) / Health Check abstraction diff --git a/docs/en/Specifications.md b/docs/en/Specifications.md index 62e324e5f9..036baa749e 100644 --- a/docs/en/Specifications.md +++ b/docs/en/Specifications.md @@ -2,9 +2,13 @@ Specification Pattern is used to define **named, reusable, combinable and testable filters** for entities and other business objects. +> A Specification is a part of the Domain Layer. + ## Installation -If you haven't installed yet, install the [Volo.Abp.Specifications](https://abp.io/package-detail/Volo.Abp.Specifications) package to your project. You can use the [ABP CLI](CLI.md) *add-package* command in a command line terminal when the current folder is the root folder of your project (`.csproj`): +> This package is **already installed** when you use the startup templates. So, most of the times you don't need to manually install it. + +Install the [Volo.Abp.Specifications](https://abp.io/package-detail/Volo.Abp.Specifications) package to your project. You can use the [ABP CLI](CLI.md) *add-package* command in a command line terminal when the current folder is the root folder of your project (`.csproj`): ````bash abp add-package Volo.Abp.Specifications diff --git a/docs/en/Startup-Templates/Application.md b/docs/en/Startup-Templates/Application.md index 8cccf32382..81f0170e59 100644 --- a/docs/en/Startup-Templates/Application.md +++ b/docs/en/Startup-Templates/Application.md @@ -97,7 +97,7 @@ A `BookType` enum and a `BookConsts` class (which may have some constant fields #### .Domain Project -This is the domain layer of the solution. It mainly contains [entities, aggregate roots](../Entities.md), [domain services](../Domain-Services.md), [value types](../Value-Types.md), [repository interfaces](../Repositories.md) and other domain objects. +This is the domain layer of the solution. It mainly contains [entities, aggregate roots](../Entities.md), [domain services](../Domain-Services.md), [value objects](../Value-Objects.md), [repository interfaces](../Repositories.md) and other domain objects. A `Book` entity, a `BookManager` domain service and an `IBookRepository` interface are good candidates for this project. diff --git a/docs/en/Startup-Templates/Index.md b/docs/en/Startup-Templates/Index.md index 0c788a6a9c..b73779ecb8 100644 --- a/docs/en/Startup-Templates/Index.md +++ b/docs/en/Startup-Templates/Index.md @@ -5,3 +5,4 @@ While you can start with an empty project and add needed packages manually, star * [**app**](Application.md): Application template. * [**module**](Module.md): Module/service template. * [**console**](Console.md): Console template. +* [**WPF**](WPF.md): WPF template. diff --git a/docs/en/Startup-Templates/WPF.md b/docs/en/Startup-Templates/WPF.md new file mode 100644 index 0000000000..7eb6a5c73e --- /dev/null +++ b/docs/en/Startup-Templates/WPF.md @@ -0,0 +1,27 @@ +# WPF Application Startup Template + +This template is used to create a minimalist WPF application project. + +## How to Start With? + +First, install the [ABP CLI](../CLI.md) if you haven't installed before: + +````bash +dotnet tool install -g Volo.Abp.Cli +```` + +Then use the `abp new` command in an empty folder to create a new solution: + +````bash +abp new Acme.MyWpfApp -t wpf +```` + +`Acme.MyWpfApp` is the solution name, like *YourCompany.YourProduct*. You can use single level, two-levels or three-levels naming. + +## Solution Structure + +After you use the above command to create a solution, you will have a solution like shown below: + +![basic-wpf-application-solution](../images/basic-wpf-application-solution.png) + +* `HelloWorldService` is a sample service that implements the `ITransientDependency` interface to register this service to the [dependency injection](../Dependency-Injection.md) system. \ No newline at end of file diff --git a/docs/en/Swagger.md b/docs/en/Swagger.md new file mode 100644 index 0000000000..1fda8a0cd7 --- /dev/null +++ b/docs/en/Swagger.md @@ -0,0 +1,3 @@ +# Swagger UI Integration + +TODO \ No newline at end of file diff --git a/docs/en/Tutorials/Part-10.md b/docs/en/Tutorials/Part-10.md index 6483346ea8..a9de3a062e 100644 --- a/docs/en/Tutorials/Part-10.md +++ b/docs/en/Tutorials/Part-10.md @@ -10,7 +10,7 @@ In this tutorial series, you will build an ABP based web application named `Acme.BookStore`. This application is used to manage a list of books and their authors. It is developed using the following technologies: -* **{{DB_Value}}** as the ORM provider. +* **{{DB_Value}}** as the ORM provider. * **{{UI_Value}}** as the UI Framework. This tutorial is organized as the following parts; @@ -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}} @@ -78,7 +78,7 @@ builder.Entity(b => b.ToTable(BookStoreConsts.DbTablePrefix + "Books", BookStoreConsts.DbSchema); b.ConfigureByConvention(); //auto configure for the base class props b.Property(x => x.Name).IsRequired().HasMaxLength(128); - + // ADD THE MAPPING FOR THE RELATION b.HasOne().WithMany().HasForeignKey(x => x.AuthorId).IsRequired(); }); @@ -384,8 +384,8 @@ namespace Acme.BookStore.Books return bookDto; } - public override async Task> - GetListAsync(PagedAndSortedResultRequestDto input) + public override async Task> GetListAsync( + PagedAndSortedResultRequestDto input) { await CheckGetListPolicyAsync(); @@ -485,7 +485,7 @@ namespace Acme.BookStore.Books DeletePolicyName = BookStorePermissions.Books.Create; } - public override async Task GetAsync(Guid id) + public async override Task GetAsync(Guid id) { await CheckGetPolicyAsync(); @@ -498,7 +498,7 @@ namespace Acme.BookStore.Books return bookDto; } - public override async Task> + public async override Task> GetListAsync(PagedAndSortedResultRequestDto input) { await CheckGetListPolicyAsync(); @@ -524,7 +524,7 @@ namespace Acme.BookStore.Books var authorDictionary = await GetAuthorDictionaryAsync(books); //Set AuthorName for the DTOs - bookDtos.ForEach(bookDto => bookDto.AuthorName = + bookDtos.ForEach(bookDto => bookDto.AuthorName = authorDictionary[bookDto.AuthorId].Name); //Get the total count with another query (required for the paging) @@ -622,7 +622,7 @@ namespace Acme.BookStore.Books result.Items.ShouldContain(b => b.Name == "1984" && b.AuthorName == "George Orwell"); } - + [Fact] public async Task Should_Create_A_Valid_Book() { @@ -645,7 +645,7 @@ namespace Acme.BookStore.Books result.Id.ShouldNotBe(Guid.Empty); result.Name.ShouldBe("New test book 42"); } - + [Fact] public async Task Should_Not_Create_A_Book_Without_Name() { @@ -1093,36 +1093,37 @@ Add the following field to the `@code` section of the `Books.razor` file: IReadOnlyList authorList = Array.Empty(); ```` -And fill it in the `OnInitializedAsync` method, by adding the following code to the end of the method: +Override the `OnInitializedAsync` method and adding the following code: ````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 authorList = Array.Empty(); + 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; } } diff --git a/docs/en/Tutorials/Part-2.md b/docs/en/Tutorials/Part-2.md index f4fcf61e25..7bc42b1fc9 100644 --- a/docs/en/Tutorials/Part-2.md +++ b/docs/en/Tutorials/Part-2.md @@ -590,7 +590,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 @@ -620,14 +619,14 @@ Open the `Books.razor` and replace the content as the following: @context.PublishDate.ToShortDateString() ` section with the following ````xml - - + +

@L["Books"]

- - - - + +
@@ -1196,48 +1194,67 @@ Now, we can add a modal that will be opened when we click to the button. Open the `Books.razor` and add the following code to the end of the page: ````xml - + - - @L["NewBook"] - - - - - @L["Name"] - - - - @L["Type"] - - - - @L["PublishDate"] - - - - @L["Price"] - - - - - - - +
+ + @L["NewBook"] + + + + + + + @L["Name"] + + + + + + + + + @L["Type"] + + + + @L["PublishDate"] + + + + @L["Price"] + + + + + + + + +
```` +This code requires a service; Inject the `AbpBlazorMessageLocalizerHelper` at the top of the file, just before the `@inherits...` line: + +````csharp +@inject AbpBlazorMessageLocalizerHelper LH +```` + +* The form implements validation and the `AbpBlazorMessageLocalizerHelper` is used to simply localize the validation messages. * `CreateModal` object, `CloseCreateModalAsync` and `CreateEntityAsync` method are defined by the base class. See the [Blazorise documentation](https://blazorise.com/docs/) if you want to understand the `Modal` and the other components. That's all. Run the application and try to add a new book: @@ -1250,78 +1267,81 @@ Editing a books is similar to the creating a new book. ### Actions Dropdown -Open the `Books.razor` and add the following `DataGridColumn` section inside the `DataGridColumns` as the first item: +Open the `Books.razor` and add the following `DataGridEntityActionsColumn` section inside the `DataGridColumns` as the first item: ````xml - + - - - @L["Actions"] - - - - @L["Edit"] - - - + + + - + ```` -* `OpenEditModalAsync` is defined in the base class which takes the `Id` of the entity (book) to edit. +* `OpenEditModalAsync` is defined in the base class which takes the entity (book) to edit. -This adds an "Actions" dropdown to all the books inside the `DataGrid` with an `Edit` action: +`DataGridEntityActionsColumn` component is used to show an "Actions" dropdown for each row in the `DataGrid`. `DataGridEntityActionsColumn` shows a **single button** instead of a dropdown if there is only one available action inside it: -![blazor-edit-book-action](images/blazor-edit-book-action.png) +![blazor-edit-book-action](images/blazor-edit-book-action-2.png) ### Edit Modal We can now define a modal to edit the book. Add the following code to the end of the `Books.razor` page: ````xml - + - - @EditingEntity.Name - - - - - @L["Name"] - - - - @L["Type"] - - - - @L["PublishDate"] - - - - @L["Price"] - - - - - - - +
+ + @EditingEntity.Name + + + + + + + @L["Name"] + + + + + + + + + @L["Type"] + + + + @L["PublishDate"] + + + + @L["Price"] + + + + + + + + +
```` @@ -1356,17 +1376,26 @@ You can now run the application and try to edit a book. ![blazor-edit-book-modal](images/blazor-edit-book-modal.png) +> Tip: Try to leave the *Name* field empty and submit the form to show the validation error message. + ## Deleting a Book -Open the `Books.razor` page and add the following `DropdownItem` under the "Edit" action inside the "Actions" `DropdownMenu`: +Open the `Books.razor` page and add the following `EntityAction` under the "Edit" action inside the `EntityActions`: ````xml - - @L["Delete"] - + ```` -* `DeleteEntityAsync` is defined in the base class. +* `DeleteEntityAsync` is defined in the base class that deletes the entity by performing a call to the server. +* `ConfirmationMessage` is a callback to show a confirmation message before executing the action. +* `GetDeleteConfirmationMessage` is defined in the base class. You can override this method (or pass another value to the `ConfirmationMessage` parameter) to customize the localization message. + +The "Actions" button becomes a dropdown since it has two actions now: + +![blazor-edit-book-action](images/blazor-delete-book-action.png) Run the application and try to delete a book. @@ -1377,26 +1406,22 @@ Here the complete code to create the book management CRUD page, that has been de ````xml @page "/books" @using Volo.Abp.Application.Dtos -@using Volo.Abp.BlazoriseUI @using Acme.BookStore.Books @using Acme.BookStore.Localization @using Microsoft.Extensions.Localization @inject IStringLocalizer L +@inject AbpBlazorMessageLocalizerHelper LH @inherits AbpCrudPageBase - - + +

@L["Books"]

- - + - + Clicked="OpenCreateModalAsync">@L["NewBook"]
@@ -1404,31 +1429,24 @@ Here the complete code to create the book management CRUD page, that has been de - + - - - @L["Actions"] - - - - @L["Edit"] - - - @L["Delete"] - - - + + + + - + @@ -1436,7 +1454,7 @@ Here the complete code to create the book management CRUD page, that has been de Field="@nameof(BookDto.Type)" Caption="@L["Type"]"> - @L[$"Enum:BookType:{(int)context.Type}"] + @L[$"Enum:BookType:{(int) context.Type}"]
- + - - @L["NewBook"] - - - - - @L["Name"] - - - - @L["Type"] - - - - @L["PublishDate"] - - - - @L["Price"] - - - - - - - +
+ + @L["NewBook"] + + + + + + + @L["Name"] + + + + + + + + + @L["Type"] + + + + @L["PublishDate"] + + + + @L["Price"] + + + + + + + + +
- + - - @EditingEntity.Name - - - - - @L["Name"] - - - - @L["Type"] - - - - @L["PublishDate"] - - - - @L["Price"] - - - - - - - +
+ + @EditingEntity.Name + + + + + + + @L["Name"] + + + + + + + + + @L["Type"] + + + + @L["PublishDate"] + + + + @L["Price"] + + + + + + + + +
```` diff --git a/docs/en/Tutorials/Part-4.md b/docs/en/Tutorials/Part-4.md index d9c000be5c..2262598544 100644 --- a/docs/en/Tutorials/Part-4.md +++ b/docs/en/Tutorials/Part-4.md @@ -53,7 +53,7 @@ This part covers the **server side** tests. There are several test projects in t Each project is used to test the related project. Test projects use the following libraries for testing: * [Xunit](https://xunit.github.io/) as the main test framework. -* [Shoudly](http://shouldly.readthedocs.io/en/latest/) as the assertion library. +* [Shoudly](https://github.com/shouldly/shouldly) as the assertion library. * [NSubstitute](http://nsubstitute.github.io/) as the mocking library. {{if DB=="EF"}} @@ -126,7 +126,7 @@ public async Task Should_Create_A_Valid_Book() { Name = "New test book 42", Price = 10, - PublishDate = System.DateTime.Now, + PublishDate = DateTime.Now, Type = BookType.ScienceFiction } ); @@ -208,7 +208,7 @@ namespace Acme.BookStore.Books { Name = "New test book 42", Price = 10, - PublishDate = System.DateTime.Now, + PublishDate = DateTime.Now, Type = BookType.ScienceFiction } ); diff --git a/docs/en/Tutorials/Part-5.md b/docs/en/Tutorials/Part-5.md index a293ec586e..29374419cb 100644 --- a/docs/en/Tutorials/Part-5.md +++ b/docs/en/Tutorials/Part-5.md @@ -70,7 +70,7 @@ namespace Acme.BookStore.Permissions } ```` -This is a hierarchical way of defining permission names. For example, "create book" permission name was defined as `BookStore.Books.Create`. +This is a hierarchical way of defining permission names. For example, "create book" permission name was defined as `BookStore.Books.Create`. ABP doesn't force you to a structure, but we find this way useful. ### Permission Definitions @@ -423,13 +423,13 @@ Open the `/src/app/book/book.component.html` file and replace the create button ````html - ```` -* Just added `abpPermission="BookStore.Books.Create"` that hides the button if the current user has no permission. +* Just added `*abpPermission="'BookStore.Books.Create'"` that hides the button if the current user has no permission. ### Hide the Edit and Delete Actions @@ -443,18 +443,18 @@ Open the `/src/app/book/book.component.html` file and replace the edit and delet ````html - - ```` -* Added `abpPermission="BookStore.Books.Edit"` that hides the edit action if the current user has no editing permission. -* Added `abpPermission="BookStore.Books.Delete"` that hides the delete action if the current user has no delete permission. +* Added `*abpPermission="'BookStore.Books.Edit'"` that hides the edit action if the current user has no editing permission. +* Added `*abpPermission="'BookStore.Books.Delete'"` that hides the delete action if the current user has no delete permission. {{else if UI == "Blazor"}} @@ -476,29 +476,29 @@ Adding this attribute prevents to enter this page if the current hasn't logged i The book management page has a *New Book* button and *Edit* and *Delete* actions for each book. We should hide these buttons/actions if the current user has not granted for the related permissions. -#### Get the Permissions On Initialization +The base `AbpCrudPageBase` class already has the necessary functionality for these kind of operations. + +#### Set the Policy (Permission) Names Add the following code block to the end of the `Books.razor` file: ````csharp @code { - bool canCreateBook; - bool canEditBook; - bool canDeleteBook; - - protected override async Task OnInitializedAsync() + public Books() // Constructor { - await base.OnInitializedAsync(); - - canCreateBook =await AuthorizationService.IsGrantedAsync(BookStorePermissions.Books.Create); - canEditBook = await AuthorizationService.IsGrantedAsync(BookStorePermissions.Books.Edit); - canDeleteBook = await AuthorizationService.IsGrantedAsync(BookStorePermissions.Books.Delete); + CreatePolicyName = BookStorePermissions.Books.Create; + UpdatePolicyName = BookStorePermissions.Books.Edit; + DeletePolicyName = BookStorePermissions.Books.Delete; } } ```` -We will use these `bool` fields to check the permissions. `AuthorizationService` comes from the base class as an injected property. +The base `AbpCrudPageBase` class automatically checks these permissions on the related operations. It also defines the given properties for us if we need to check them manually: + +* `HasCreatePermission`: True, if the current user has permission to create the entity. +* `HasUpdatePermission`: True, if the current user has permission to edit/update the entity. +* `HasDeletePermission`: True, if the current user has permission to delete the entity. > **Blazor Tip**: While adding the C# code into a `@code` block is fine for small code parts, it is suggested to use the code behind approach to develop a more maintainable code base when the code block becomes longer. We will use this approach for the authors part. @@ -507,32 +507,31 @@ We will use these `bool` fields to check the permissions. `AuthorizationService` Wrap the *New Book* button by an `if` block as shown below: ````xml -@if (canCreateBook) +@if (HasCreatePermission) { + Clicked="OpenCreateModalAsync">@L["NewBook"] } ```` #### Hide the Edit/Delete Actions -As similar to the *New Book* button, we can use `if` blocks to conditionally show/hide the *Edit* and *Delete* actions: +`EntityAction` component defines `RequiredPolicy` attribute (parameter) to conditionally show the action based on the user permissions. + +Update the `EntityActions` section as shown below: ````xml -@if (canEditBook) -{ - - @L["Edit"] - -} -@if (canDeleteBook) -{ - - @L["Delete"] - -} + + + + ```` #### About the Permission Caching @@ -587,54 +586,39 @@ if (await context.IsGrantedAsync(BookStorePermissions.Books.Default)) } ```` -You also need to add `async` keyword to the `ConfigureMenuAsync` method and re-arrange the return values. The final `BookStoreMenuContributor` class should be the following: +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: ````csharp -using System.Threading.Tasks; -using Acme.BookStore.Localization; -using Acme.BookStore.Permissions; -using Volo.Abp.UI.Navigation; - -namespace Acme.BookStore.Blazor +private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) { - public class BookStoreMenuContributor : IMenuContributor - { - public async Task ConfigureMenuAsync(MenuConfigurationContext context) - { - if(context.Menu.DisplayName != StandardMenus.Main) - { - return; - } + var l = context.GetLocalizer(); - var l = context.GetLocalizer(); - - context.Menu.Items.Insert( - 0, - new ApplicationMenuItem( - "BookStore.Home", - l["Menu:Home"], - "/", - icon: "fas fa-home" - ) - ); + context.Menu.Items.Insert( + 0, + new ApplicationMenuItem( + "BookStore.Home", + l["Menu:Home"], + "/", + icon: "fas fa-home" + ) + ); - var bookStoreMenu = new ApplicationMenuItem( - "BooksStore", - l["Menu:BookStore"], - icon: "fa fa-book" - ); + var bookStoreMenu = new ApplicationMenuItem( + "BooksStore", + l["Menu:BookStore"], + icon: "fa fa-book" + ); - context.Menu.AddItem(bookStoreMenu); + context.Menu.AddItem(bookStoreMenu); - if (await context.IsGrantedAsync(BookStorePermissions.Books.Default)) - { - bookStoreMenu.AddItem(new ApplicationMenuItem( - "BooksStore.Books", - l["Menu:Books"], - url: "/books" - )); - } - } + //CHECK the PERMISSION + if (await context.IsGrantedAsync(BookStorePermissions.Books.Default)) + { + bookStoreMenu.AddItem(new ApplicationMenuItem( + "BooksStore.Books", + l["Menu:Books"], + url: "/books" + )); } } ```` diff --git a/docs/en/Tutorials/Part-9.md b/docs/en/Tutorials/Part-9.md index 374efff2b4..a1b4b03e21 100644 --- a/docs/en/Tutorials/Part-9.md +++ b/docs/en/Tutorials/Part-9.md @@ -843,15 +843,8 @@ Create a new Razor Component Page, `/Pages/Authors.razor`, in the `Acme.BookStor ````xml @page "/authors" @using Acme.BookStore.Authors -@using Acme.BookStore.Localization -@using Microsoft.AspNetCore.Authorization -@using Microsoft.Extensions.Localization -@using Volo.Abp.ObjectMapping +@inherits BookStoreComponentBase @inject IAuthorAppService AuthorAppService -@inject IStringLocalizer L -@inject IAuthorizationService AuthorizationService -@inject IUiMessageService UiMessageService -@inject IObjectMapper ObjectMapper @@ -1048,10 +1041,10 @@ namespace Acme.BookStore.Blazor.Pages { CanCreateAuthor = await AuthorizationService .IsGrantedAsync(BookStorePermissions.Authors.Create); - + CanEditAuthor = await AuthorizationService .IsGrantedAsync(BookStorePermissions.Authors.Edit); - + CanDeleteAuthor = await AuthorizationService .IsGrantedAsync(BookStorePermissions.Authors.Delete); } @@ -1105,7 +1098,7 @@ namespace Acme.BookStore.Blazor.Pages private async Task DeleteAuthorAsync(AuthorDto author) { var confirmMessage = L["AuthorDeletionConfirmationMessage", author.Name]; - if (!await UiMessageService.ConfirmAsync(confirmMessage)) + if (!await Message.Confirm(confirmMessage)) { return; } @@ -1195,4 +1188,4 @@ That's all! This is a fully working CRUD page, you can create, edit and delete t ## The Next Part -See the [next part](Part-10.md) of this tutorial. \ No newline at end of file +See the [next part](Part-10.md) of this tutorial. diff --git a/docs/en/Tutorials/images/blazor-bookstore-book-list.png b/docs/en/Tutorials/images/blazor-bookstore-book-list.png index 91450f47c2..18bb26ccb1 100644 Binary files a/docs/en/Tutorials/images/blazor-bookstore-book-list.png and b/docs/en/Tutorials/images/blazor-bookstore-book-list.png differ diff --git a/docs/en/Tutorials/images/blazor-delete-book-action.png b/docs/en/Tutorials/images/blazor-delete-book-action.png new file mode 100644 index 0000000000..f2b0b83f30 Binary files /dev/null and b/docs/en/Tutorials/images/blazor-delete-book-action.png differ diff --git a/docs/en/Tutorials/images/blazor-edit-book-action-2.png b/docs/en/Tutorials/images/blazor-edit-book-action-2.png new file mode 100644 index 0000000000..70856ab325 Binary files /dev/null and b/docs/en/Tutorials/images/blazor-edit-book-action-2.png differ diff --git a/docs/en/UI/Angular/Config-State-Service.md b/docs/en/UI/Angular/Config-State-Service.md new file mode 100644 index 0000000000..c810562623 --- /dev/null +++ b/docs/en/UI/Angular/Config-State-Service.md @@ -0,0 +1,135 @@ +# Config State Service + +`ConfigStateService` is a singleton service, i.e. provided in root level of your application, and keeps the application configuration response in the internal store. + +## Before Use + +In order to use the `ConfigStateService` you must inject it in your class as a dependency. + +```js +import { ConfigStateService } from '@abp/ng.core'; + +@Component({ + /* class metadata here */ +}) +class DemoComponent { + constructor(private config: ConfigStateService) {} +} +``` + +You do not have to provide the `ConfigStateService` at module or component/directive level, because it is already **provided in root**. + +## Get Methods + +`ConfigStateService` has numerous get methods which allow you to get a specific configuration or all configurations. + +Get methods with "$" at the end of the method name (e.g. `getAll$`) return an RxJs stream. The streams are triggered when set or patched the state. + +### How to Get All Configurations + +You can use the `getAll` or `getAll$` method of `ConfigStateService` to get all of the applcation configuration response object. It is used as follows: + +```js +// this.config is instance of ConfigStateService + +const config = this.config.getAll(); + +// or +this.config.getAll$().subscribe(config => { + // use config here +}) +``` + +### How to Get a Specific Configuration + +You can use the `getOne` or `getOne$` method of `ConfigStateService` to get a specific configuration property. For that, the property name should be passed to the method as parameter. + +```js +// this.config is instance of ConfigStateService + +const currentUser = this.config.getOne("currentUser"); + +// or +this.config.getOne$("currentUser").subscribe(currentUser => { + // use currentUser here +}) +``` + +On occasion, you will probably want to be more specific than getting just the current user. For example, here is how you can get the `tenantId`: + +```js +const tenantId = this.config.getDeep("currentUser.tenantId"); + +// or +this.config.getDeep$("currentUser.tenantId").subscribe(tenantId => { + // use tenantId here +}) +``` + +or by giving an array of keys as parameter: + +```js +const tenantId = this.config.getDeep(["currentUser", "tenantId"]); +``` + +FYI, `getDeep` is able to do everything `getOne` does. Just keep in mind that `getOne` is slightly faster. + +### How to Get a Feature + +You can use the `getFeature` or `getFeature$` method of `ConfigStateService` to get a feature value. For that, the feature name should be passed to the method as parameter. + +```js +// this.config is instance of ConfigStateService + +const enableLdapLogin = this.configStateService.getFeature("Account.EnableLdapLogin"); + +// or +this.config.getFeature$("Account.EnableLdapLogin").subscribe(enableLdapLogin => { + // use enableLdapLogin here +}) +``` + +> For more information, see the [features document](./Features). + +### How to Get a Setting + +You can use the `getSetting` or `getSetting$` method of `ConfigStateService` to get a setting. For that, the setting name should be passed to the method as parameter. + +```js +// this.config is instance of ConfigStateService + +const twoFactorBehaviour = this.configStateService.getSetting("Abp.Identity.TwoFactor.Behaviour"); + +// or +this.config.getSetting$("Abp.Identity.TwoFactor.Behaviour").subscribe(twoFactorBehaviour => { + // use twoFactorBehaviour here +}) +``` + +> For more information, see the [settings document](./Settings). + +#### State Properties + +Please refer to `ApplicationConfiguration.Response` type for all the properties you can get with `getOne` and `getDeep`. It can be found in the [application-configuration.ts file](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/application-configuration.ts#L4). + + +## Set State + +`ConfigStateService` has a method named `setState` which allow you to set the state value. + +You can get the application configuration response and set the `ConfigStateService` state value as shown below: + +```js +import {ApplicationConfigurationService, ConfigStateService} from '@abp/ng.core'; + +constructor(private applicationConfigurationService: ApplicationConfigurationService, private config: ConfigStateService) { + this.applicationConfigurationService.getConfiguration().subscribe(config => { + this.config.setState(config); + }) +} +``` + +## See Also + +- [Settings](./Settings.md) +- [Features](./Features.md) diff --git a/docs/en/UI/Angular/Config-State.md b/docs/en/UI/Angular/Config-State.md index 8014cd9b14..d6774bb0cb 100644 --- a/docs/en/UI/Angular/Config-State.md +++ b/docs/en/UI/Angular/Config-State.md @@ -1,192 +1 @@ -# Config State - -`ConfigStateService` is a singleton service, i.e. provided in root level of your application, and is actually a façade for interacting with application configuration state in the `Store`. - -## Before Use - -In order to use the `ConfigStateService` you must inject it in your class as a dependency. - -```js -import { ConfigStateService } from '@abp/ng.core'; - -@Component({ - /* class metadata here */ -}) -class DemoComponent { - constructor(private config: ConfigStateService) {} -} -``` - -You do not have to provide the `ConfigStateService` at module or component/directive level, because it is already **provided in root**. - -## Selector Methods - -`ConfigStateService` has numerous selector methods which allow you to get a specific configuration or all configurations from the `Store`. - -### How to Get All Configurations From the Store - -You can use the `getAll` method of `ConfigStateService` to get all of the configuration object from the store. It is used as follows: - -```js -// this.config is instance of ConfigStateService - -const config = this.config.getAll(); -``` - -### How to Get a Specific Configuration From the Store - -You can use the `getOne` method of `ConfigStateService` to get a specific configuration property from the store. For that, the property name should be passed to the method as parameter. - -```js -// this.config is instance of ConfigStateService - -const currentUser = this.config.getOne("currentUser"); -``` - -On occasion, you will probably want to be more specific than getting just the current user. For example, here is how you can get the `tenantId`: - -```js -const tenantId = this.config.getDeep("currentUser.tenantId"); -``` - -or by giving an array of keys as parameter: - -```js -const tenantId = this.config.getDeep(["currentUser", "tenantId"]); -``` - -FYI, `getDeep` is able to do everything `getOne` does. Just keep in mind that `getOne` is slightly faster. - -#### Config State Properties - -Please refer to `Config.State` type for all the properties you can get with `getOne` and `getDeep`. It can be found in the [config.ts file](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/config.ts#L7). - -### How to Get the Application Information From the Store - -The `getApplicationInfo` method is used to get the application information from the environment variables stored as the config state. This is how you can use it: - -```js -// this.config is instance of ConfigStateService - -const appInfo = this.config.getApplicationInfo(); -``` - -This method never returns `undefined` or `null` and returns an empty object literal (`{}`) instead. In other words, you will never get an error when referring to the properties of `appInfo` above. - -#### Application Information Properties - -Please refer to `Config.Application` type for all the properties you can get with `getApplicationInfo`. It can be found in the [config.ts file](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/config.ts#L21). - -### How to Get API URL From the Store - -The `getApplicationInfo` method is used to get a specific API URL from the environment variables stored as the config state. This is how you can use it: - -```js -// this.config is instance of ConfigStateService - -const apiUrl = this.config.getApiUrl(); -// environment.apis.default.url - -const searchUrl = this.config.getApiUrl("search"); -// environment.apis.search.url -``` - -This method returns the `url` of a specific API based on the key given as its only parameter. If there is no key, `'default'` is used. - -### How to Get a Specific Permission From the Store - -You can use the `getGrantedPolicy` method of `ConfigStateService` to get a specific permission from the configuration state. For that, you should pass a policy key as parameter to the method. - -```js -// this.config is instance of ConfigStateService - -const hasIdentityPermission = this.config.getGrantedPolicy("Abp.Identity"); -// true -``` - -You may also **combine policy keys** to fine tune your selection: - -```js -// this.config is instance of ConfigStateService - -const hasIdentityAndAccountPermission = this.config.getGrantedPolicy( - "Abp.Identity && Abp.Account" -); -// false - -const hasIdentityOrAccountPermission = this.config.getGrantedPolicy( - "Abp.Identity || Abp.Account" -); -// true -``` - -Please consider the following **rules** when creating your permission selectors: - -- Maximum 2 keys can be combined. -- `&&` operator looks for both keys. -- `||` operator looks for either key. -- Empty string `''` as key will return `true` -- Using an operator without a second key will return `false` - -### How to Get Translations From the Store - -The `getLocalization` method of `ConfigStateService` is used for translations. Here are some examples: - -```js -// this.config is instance of ConfigStateService - -const identity = this.config.getLocalization("AbpIdentity::Identity"); -// 'identity' - -const notFound = this.config.getLocalization("AbpIdentity::IDENTITY"); -// 'AbpIdentity::IDENTITY' - -const defaultValue = this.config.getLocalization({ - key: "AbpIdentity::IDENTITY", - defaultValue: "IDENTITY" -}); -// 'IDENTITY' -``` - -Please check out the [localization documentation](./Localization.md) for details. - -## Dispatch Methods - -`ConfigStateService` has several dispatch methods which allow you to conveniently dispatch predefined actions to the `Store`. - -### How to Get Application Configuration From Server - -The `dispatchGetAppConfiguration` triggers a request to an endpoint that responds with the application state and then places this response to the `Store` as configuration state. - -```js -// this.config is instance of ConfigStateService - -this.config.dispatchGetAppConfiguration(); -// returns a state stream which emits after dispatch action is complete -``` - -Note that **you do not have to call this method at application initiation**, because the application configuration is already being received from the server at start. - -### How to Set the Environment - -The `dispatchSetEnvironment` places environment variables passed to it in the `Store` under the configuration state. Here is how it is used: - -```js -// this.config is instance of ConfigStateService - -this.config.dispatchSetEnvironment({ - /* environment properties here */ -}); -// returns a state stream which emits after dispatch action is complete -``` - -Note that **you do not have to call this method at application initiation**, because the environment variables are already being stored at start. - -#### Environment Properties - -Please refer to `Config.Environment` type for all the properties you can pass to `dispatchSetEnvironment` as parameter. It can be found in the [config.ts file](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/config.ts#L13). - -## See Also - -- [Settings](./Settings.md) -- [Features](./Features.md) +**ConfigState has been deprecated.** Use the [ConfigStateService](./Config-State-Service) instead. \ No newline at end of file diff --git a/docs/en/UI/Angular/Environment.md b/docs/en/UI/Angular/Environment.md index 04bf8f98c4..8c6fb28ce7 100644 --- a/docs/en/UI/Angular/Environment.md +++ b/docs/en/UI/Angular/Environment.md @@ -101,3 +101,81 @@ export interface RemoteEnv { * `customMergeFn`: You can also provide your own merge function as shown in the example. It will take two parameters, `localEnv: Partial` and `remoteEnv` and it needs to return a `Config.Environment` object. * `method`: HTTP method to be used when retrieving environment config. Default: `GET` * `headers`: If extra headers are needed for the request, it can be set through this field. + +## EnvironmentService + +` EnvironmentService` is a singleton service, i.e. provided in root level of your application, and keeps the environment in the internal store. + + +### Before Use + +In order to use the `EnvironmentService` you must inject it in your class as a dependency. + +```js +import { EnvironmentService } from '@abp/ng.core'; + +@Component({ + /* class metadata here */ +}) +class DemoComponent { + constructor(private environment: EnvironmentService) {} +} +``` + +You do not have to provide the `EnvironmentService` at module or component/directive level, because it is already **provided in root**. + + +### Get Methods + +`EnvironmentService` has numerous get methods which allow you to get a specific value or all environment object. + +Get methods with "$" at the end of the method name (e.g. `getEnvironment$`) return an RxJs stream. The streams are triggered when set or patched the state. + +#### How to Get Environment Object + +You can use the `getEnvironment` or `getEnvironment$` method of `EnvironmentService` to get all of the environment object. It is used as follows: + +```js +// this.environment is instance of EnvironmentService + +const environment = this.environment.getAll(); + +// or +this.environment.getAll$().subscribe(environment => { + // use environment here +}) +``` + +#### How to Get API URL + +The `getApiUrl` or `getApiUrl$` method is used to get a specific API URL from the environment object. This is how you can use it: + +```js +// this.environment is instance of EnvironmentService + +const apiUrl = this.environment.getApiUrl(); +// environment.apis.default.url + +this.environment.getApiUrl$("search").subscribe(searchUrl => { +// environment.apis.search.url +}) +``` + +This method returns the `url` of a specific API based on the key given as its only parameter. If there is no key, `'default'` is used. + + +#### How to Set the Environment + +`EnvironmentService` has a method named `setState` which allow you to set the state value. + +```js +// this.environment is instance of EnvironmentService + +this.environment.setState(newEnvironmentObject); +``` + +Note that **you do not have to call this method at application initiation**, because the environment variables are already being stored at start. + +#### Environment Properties + +Please refer to `Environment` type for all the properties. It can be found in the [config.ts file](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/config.ts#L13). \ No newline at end of file diff --git a/docs/en/UI/Angular/List-Service.md b/docs/en/UI/Angular/List-Service.md index 7cc31a46fd..016b891159 100644 --- a/docs/en/UI/Angular/List-Service.md +++ b/docs/en/UI/Angular/List-Service.md @@ -68,6 +68,50 @@ Bind `ListService` to ngx-datatable like this: ``` +## Extending query with custom variables + +You can extend the query parameter of the `ListService`'s `hookToQuery` method. + +Firstly, you should pass your own type to `ListService` as shown below: + +```typescript +constructor(public readonly list: ListService) { } +``` + +Then update the `bookStreamCreator` constant like following: + +```typescript +const bookStreamCreator = (query) => this.bookService.getList({...query, name: 'name here'}); +``` + +You can also create your params object. + +Define a variable like this: + +```typescript +booksSearchParams = {} as BooksSearchParamsDto; +``` + +Update the `bookStreamCreator` constant: + +```typescript +const bookStreamCreator = (query) => this.bookService.getList({...query, ...this.booksSearchParams}); +``` + +Then you can place inputs to the HTML: + +```html +
+ +
+``` + +`ListService` emits the hookToQuery stream when you call the `this.list.get()` method. ## Usage with Observables diff --git a/docs/en/UI/Angular/Localization.md b/docs/en/UI/Angular/Localization.md index 2320dc7952..6c7e6084a6 100644 --- a/docs/en/UI/Angular/Localization.md +++ b/docs/en/UI/Angular/Localization.md @@ -100,36 +100,6 @@ this.localizationService.get('Resource::Key'); this.localizationService.get({ key: 'Resource::Key', defaultValue: 'Default Value' }); ``` -### Using the Config State - -In order to you `getLocalization` method you should import ConfigState. - -```js -import { ConfigState } from '@abp/ng.core'; -``` - -Then you can use it as followed: - -```js -this.store.selectSnapshot(ConfigState.getLocalization('ResourceName::Key')); -``` - -`getLocalization` method can be used with both `localization key` and [`LocalizationWithDefault`](https://github.com/abpframework/abp/blob/dev/npm/ng-packs/packages/core/src/lib/models/config.ts#L34) interface. - -```js -this.store.selectSnapshot( - ConfigState.getLocalization( - { - key: 'AbpIdentity::UserDeletionConfirmation', - defaultValue: 'Default Value', - }, - 'John', - ), -); -``` - -Localization resources are stored in the `localization` property of `ConfigState`. - ## RTL Support As of v2.9 ABP has RTL support. If you are generating a new project with v2.9 and above, everything is set, you do not need to do any changes. If you are migrating your project from an earlier version, please follow the 2 steps below: @@ -193,44 +163,129 @@ import { Component } from '@angular/core'; export class AppComponent {} ``` -## Mapping of Culture Name to Angular Locale File Name +## Registering a New Locale + +Since ABP has more than one language, Angular locale files loads lazily using [Webpack's import function](https://webpack.js.org/api/module-methods/#import-1) to avoid increasing the bundle size and register to Angular core using the [`registerLocaleData`](https://angular.io/api/common/registerLocaleData) function. The chunks to be included in the bundle are specified by the [Webpack's magic comments](https://webpack.js.org/api/module-methods/#magic-comments) as hard-coded. Therefore a `registerLocale` function that returns Webpack `import` function must be passed to `CoreModule`. + +### registerLocaleFn + +`registerLocale` function that exported from `@abp/ng.core/locale` package is a higher order function that accepts `cultureNameLocaleFileMap` object and `errorHandlerFn` function as params and returns Webpack `import` function. A `registerLocale` function must be passed to the `forRoot` of the `CoreModule` as shown below: + +```js +// app.module.ts + +import { registerLocale } from '@abp/ng.core/locale'; +// if you have commercial license and the language management module, add the below import +// import { registerLocale } from '@volo/abp.ng.language-management/locale'; + + +@NgModule({ + imports: [ + // ... + CoreModule.forRoot({ + // ...other options, + registerLocaleFn: registerLocale( + // you can pass the cultureNameLocaleFileMap and errorHandlerFn as optionally + { + cultureNameLocaleFileMap: { 'pt-BR': 'pt' }, + errorHandlerFn: ({ resolve, reject, locale, error }) => { + // the error can be handled here + }, + }, + ) + }), + //... + ] +``` + + +### Mapping of Culture Name to Angular Locale File Name Some of the culture names defined in .NET do not match Angular locales. In such cases, the Angular app throws an error like below at runtime: ![locale-error](./images/locale-error.png) -If you see an error like this, you should pass the `cultureNameLocaleFileMap` property like below to CoreModule's forRoot static method. +If you see an error like this, you should pass the `cultureNameLocaleFileMap` property like below to the `registerLocale` function. ```js // app.module.ts +import { registerLocale } from '@abp/ng.core/locale'; +// if you have commercial license and the language management module, add the below import +// import { registerLocale } from '@volo/abp.ng.language-management/locale'; + + @NgModule({ imports: [ - // other imports - CoreModule.forRoot({ - // other options - cultureNameLocaleFileMap: { - "DotnetCultureName": "AngularLocaleFileName", - "pt-BR": "pt" // example - } - }) + // ... + CoreModule.forRoot({ + // ...other options, + registerLocaleFn: registerLocale( + { + cultureNameLocaleFileMap: { + "DotnetCultureName": "AngularLocaleFileName", + "pt-BR": "pt" // example + }, + }, + ) + }), //... ``` See [all locale files in Angular](https://github.com/angular/angular/tree/master/packages/common/locales). -## Adding new culture +### Adding a New Culture + +Add the below code to the `app.module.ts` by replacing `your-locale` placeholder with a correct locale name. ```js //app.module.ts -import { storeLocaleData } from '@abp/ng.core'; +import { storeLocaleData } from '@abp/ng.core/locale'; import( /* webpackChunkName: "_locale-your-locale-js"*/ /* webpackMode: "eager" */ '@angular/common/locales/your-locale.js' ).then(m => storeLocaleData(m.default, 'your-locale')); ``` + +...or a custom `registerLocale` function can be passed to the `CoreModule`: + +```js +// register-locale.ts + +import { differentLocales } from '@abp/ng.core'; +export function registerLocale(locale: string) { + return import( + /* webpackChunkName: "_locale-[request]"*/ + /* webpackInclude: /[/\\](en|fr).js/ */ + /* webpackExclude: /[/\\]global|extra/ */ + `@angular/common/locales/${differentLocales[locale] || locale}.js` + ) +} + +// app.module.ts + +import { registerLocale } from './register-locale'; + +@NgModule({ + imports: [ + // ... + CoreModule.forRoot({ + // ...other options, + registerLocaleFn: registerLocale + }), + //... + ] +``` + +After this custom `registerLocale` function, since the en and fr added to the `webpackInclude`, only en and fr locale files will be created as chunks: + +![locale chunks](https://user-images.githubusercontent.com/34455572/98203212-acaa2100-1f44-11eb-85af-4eb66d296326.png) + +Which locale files you add to `webpackInclude` magic comment, they will be included in the bundle + + ## See Also * [Localization in ASP.NET Core](../../Localization.md) diff --git a/docs/en/UI/Angular/Permission-Management.md b/docs/en/UI/Angular/Permission-Management.md index fe97461f03..b8125bb2a3 100644 --- a/docs/en/UI/Angular/Permission-Management.md +++ b/docs/en/UI/Angular/Permission-Management.md @@ -2,22 +2,46 @@ A permission is a simple policy that is granted or prohibited for a particular user, role or client. You can read more about [authorization in ABP](../../Authorization.md) document. -You can get permission of authenticated user using `getGrantedPolicy` selector of `ConfigState`. +You can get permission of authenticated user using `getGrantedPolicy` or `getGrantedPolicy$` method of `PermissionService`. + +> ConfigState's getGrantedPolicy selector and ConfigStateService's getGrantedPolicy method deprecated. Use permission service's `getGrantedPolicy$` or `getGrantedPolicy`methods instead You can get permission as boolean value: ```js -import { ConfigStateService } from '@abp/ng.core'; +import { PermissionService } from '@abp/ng.core'; export class YourComponent { - constructor(private config: ConfigStateService) {} + constructor(private permissionService: PermissionService) {} ngOnInit(): void { - const canCreate = this.config.getGrantedPolicy('AbpIdentity.Roles.Create'); + const canCreate = this.permissionService.getGrantedPolicy('AbpIdentity.Roles.Create'); } } ``` +You may also **combine policy keys** to fine tune your selection: + +```js +// this.permissionService is instance of PermissionService + +const hasIdentityAndAccountPermission = this.permissionService.getGrantedPolicy( + "Abp.Identity && Abp.Account" +); + +const hasIdentityOrAccountPermission = this.permissionService.getGrantedPolicy( + "Abp.Identity || Abp.Account" +); +``` + +Please consider the following **rules** when creating your permission selectors: + +- Maximum 2 keys can be combined. +- `&&` operator looks for both keys. +- `||` operator looks for either key. +- Empty string `''` as key will return `true` +- Using an operator without a second key will return `false` + ## Permission Directive You can use the `PermissionDirective` to manage visibility of a DOM Element accordingly to user's permission. @@ -30,8 +54,6 @@ You can use the `PermissionDirective` to manage visibility of a DOM Element acco As shown above you can remove elements from DOM with `abpPermission` structural directive. -The directive can also be used as an attribute directive but we recommend to you to use it as a structural directive. - ## Permission Guard You can use `PermissionGuard` if you want to control authenticated user's permission to access to the route during navigation. @@ -55,4 +77,4 @@ const routes: Routes = [ ]; ``` -Granted Policies are stored in the `auth` property of `ConfigState`. +Granted Policies are stored in the `auth` property of `ConfigState`. \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Branding.md b/docs/en/UI/AspNetCore/Branding.md index ee19cd5845..e4a9ee0f3b 100644 --- a/docs/en/UI/AspNetCore/Branding.md +++ b/docs/en/UI/AspNetCore/Branding.md @@ -11,7 +11,7 @@ The screenshot below shows *MyProject* as the application name: You can implement the `IBrandingProvider` interface or inherit from the `DefaultBrandingProvider` to set the application name: ````csharp -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; +using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; namespace MyProject.Web diff --git a/docs/en/UI/AspNetCore/Client-Side-Package-Management.md b/docs/en/UI/AspNetCore/Client-Side-Package-Management.md index 77dee7a383..645200a363 100644 --- a/docs/en/UI/AspNetCore/Client-Side-Package-Management.md +++ b/docs/en/UI/AspNetCore/Client-Side-Package-Management.md @@ -76,7 +76,8 @@ module.exports = { "@libs": "./wwwroot/libs" }, clean: [ - "@libs" + "@libs", + "!@libs/**/foo.txt" ], mappings: { @@ -85,7 +86,7 @@ module.exports = { ```` * **aliases** section defines standard aliases (placeholders) that can be used in the mapping paths. **@node_modules** and **@libs** are required (by the standard packages), you can define your own aliases to reduce duplication. -* **clean** section is a list of folders to clean before copying the files. +* **clean** section is a list of folders to clean before copying the files. Glob matching and negation is enabled, so you can fine-tune what to delete and keep. The example above will clean everything inside `./wwwroot/libs`, but keep any `foo.txt` files. * **mappings** section is a list of mappings of files/folders to copy. This example does not copy any resource itself, but depends on a standard package. An example mapping configuration is shown below: diff --git a/docs/en/UI/AspNetCore/Customization-User-Interface.md b/docs/en/UI/AspNetCore/Customization-User-Interface.md index ccb832ccc7..111a43ddcb 100644 --- a/docs/en/UI/AspNetCore/Customization-User-Interface.md +++ b/docs/en/UI/AspNetCore/Customization-User-Interface.md @@ -1,6 +1,6 @@ # ASP.NET Core (MVC / Razor Pages) User Interface Customization Guide -This document explains how to override the user interface of a depended [application module](../../Modules/Index.md) for ASP.NET Core MVC / Razor Page applications. +This document explains how to override the user interface of a depended [application module](../../Modules/Index.md) or [theme](Theming.md) for ASP.NET Core MVC / Razor Page applications. ## Overriding a Page @@ -28,15 +28,15 @@ namespace Acme.BookStore.Web.Pages.Identity.Users public class MyEditModalModel : EditModalModel { public MyEditModalModel( - IIdentityUserAppService identityUserAppService, + IIdentityUserAppService identityUserAppService, IIdentityRoleAppService identityRoleAppService ) : base( - identityUserAppService, + identityUserAppService, identityRoleAppService) { } - public override async Task OnPostAsync() + public async override Task OnPostAsync() { //TODO: Additional logic await base.OnPostAsync(); @@ -84,10 +84,10 @@ Create a page model class deriving from the ` LoginModel ` (defined in the ` Vol public class MyLoginModel : LoginModel { public MyLoginModel( - IAuthenticationSchemeProvider schemeProvider, + IAuthenticationSchemeProvider schemeProvider, IOptions accountOptions ) : base( - schemeProvider, + schemeProvider, accountOptions) { @@ -437,7 +437,7 @@ See the layouts section below to learn more about the layout system. Layout system allows themes to define standard, named layouts and allows any page to select a proper layout for its purpose. There are three pre-defined layouts: -* "**Application**": The main (and the default) layout for an application. It typically contains header, menu (sidebar), footer, toolbar... etc. +* "**Application**": The main (and the default) layout for an application. It typically contains header, menu (sidebar), footer, toolbar... etc. * "**Account**": This layout is used by login, register and other similar pages. It is used for the pages under the `/Pages/Account` folder by default. * "**Empty**": Empty and minimal layout. diff --git a/docs/en/UI/AspNetCore/Data-Table-Column-Extensions.md b/docs/en/UI/AspNetCore/Data-Table-Column-Extensions.md new file mode 100644 index 0000000000..fec0ac71fb --- /dev/null +++ b/docs/en/UI/AspNetCore/Data-Table-Column-Extensions.md @@ -0,0 +1,161 @@ +# Data Table Column Extensions for ASP.NET Core UI + +## Introduction + +Data table column extension system allows you to add a **new table column** on the user interface. The example below adds a new column with the "Social security no" title: + +![user-action-extension-click-me](../../images/table-column-extension-example.png) + +You can use the standard column options to fine control the table column. + +> Note that this is a low level API to find control the table column. If you want to show an extension property on the table, see the [module entity extension](../../Module-Entity-Extensions.md) document. + +## How to Set Up + +### Create a JavaScript File + +First, add a new JavaScript file to your solution. We added inside the `/Pages/Identity/Users` folder of the `.Web` project: + +![user-action-extension-on-solution](../../images/user-action-extension-on-solution.png) + +Here, the content of this JavaScript file: + +```js +abp.ui.extensions.tableColumns + .get('identity.user') + .addContributor(function (columnList) { + columnList.addTail({ //add as the last column + title: 'Social security no', + data: 'extraProperties.SocialSecurityNumber', + orderable: false, + render: function (data, type, row) { + if (row.extraProperties.SocialSecurityNumber) { + return '' + + row.extraProperties.SocialSecurityNumber + + ''; + } else { + return 'undefined'; + } + } + }); + }); +``` + +This example defines a custom `render` function to return a custom HTML to render in the column. + +### Add the File to the User Management Page + +Then you need to add this JavaScript file to the user management page. You can take the power of the [Bundling & Minification system](https://docs.abp.io/en/abp/latest/UI/AspNetCore/Bundling-Minification). + +Write the following code inside the `ConfigureServices` of your module class: + +```csharp +Configure(options => +{ + options.ScriptBundles.Configure( + typeof(Volo.Abp.Identity.Web.Pages.Identity.Users.IndexModel).FullName, + bundleConfiguration => + { + bundleConfiguration.AddFiles( + "/Pages/Identity/Users/my-user-extensions.js" + ); + }); +}); +``` + +This configuration adds `my-user-extensions.js` to the user management page of the Identity Module. `typeof(Volo.Abp.Identity.Web.Pages.Identity.Users.IndexModel).FullName` is the name of the bundle in the user management page. This is a common convention used for all the ABP Commercial modules. + +### Rendering the Column + +This example assumes that you've defined a `SocialSecurityNumber` extra property using the [module entity extension](../../Module-Entity-Extensions.md) system. However; + +* You can add a new column that is related to an existing property of the user (that was not added to the table by default). Example: + +````js +abp.ui.extensions.tableColumns + .get('identity.user') + .addContributor(function (columnList) { + columnList.addTail({ + title: 'Phone confirmed?', + data: 'phoneNumberConfirmed', + render: function (data, type, row) { + if (row.phoneNumberConfirmed) { + return 'YES'; + } else { + return 'NO'; + } + } + }); + }); +```` + +* You can add a new custom column that is not related to any entity property, but a completely custom information. Example: + +````js +abp.ui.extensions.tableColumns + .get('identity.user') + .addContributor(function (columnList) { + columnList.addTail({ + title: 'Custom column', + data: {}, + orderable: false, + render: function (data) { + if (data.phoneNumber) { + return "call: " + data.phoneNumber; + } else { + return ''; + } + } + }); + }); +```` + +## API + +This section explains details of the `abp.ui.extensions.tableColumns` JavaScript API. + +### abp.ui.extensions.tableColumns.get(entityName) + +This method is used to access the table columns for an entity of a specific module. It takes one parameter: + +* **entityName**: The name of the entity defined by the related module. + +### abp.ui.extensions.tableColumns.get(entityName).columns + +The `columns` property is used to retrieve a [doubly linked list](../Common/Utils/Linked-List.md) of previously defined columns for a table. All contributors are executed in order to prepare the final column list. This is normally called by the modules to show the columns in the table. However, you can use it if you are building your own extensible UIs. + +### abp.ui.extensions.tableColumns.get(entityName).addContributor(contributeCallback [, order]) + +The `addContributor` method covers all scenarios, e.g. you want to add your column in a different position in the list, change or remove an existing column. `addContributor` has the following parameters: + +* **contributeCallback**: A callback function that is called whenever the column list should be created. You can freely modify the column list inside this callback method. +* **order** (optional): The order of the callback in the callback list. Your callback is added to the end of the list (so, you have opportunity to modify columns added by the previous contributors). You can set it `0` to add your contributor as the first item. + +#### Example + +```js +var myColumnDefinition = { + title: 'Custom column', + data: {}, + orderable: false, + render: function(data) { + if (data.phoneNumber) { + return "call: " + data.phoneNumber; + } else { + return ''; + } + } +}; + +abp.ui.extensions.tableColumns + .get('identity.user') + .addContributor(function (columnList) { + // Remove an item from actionList + columnList.dropHead(); + + // Add a new item to the actionList + columnList.addHead(myColumnDefinition); + }); +``` + +> `columnList` is [linked list](../Common/Utils/Linked-List.md). You can use its methods to build a list of columns however you need. diff --git a/docs/en/UI/AspNetCore/Data-Tables.md b/docs/en/UI/AspNetCore/Data-Tables.md index 79fd6a3be1..a9dbf1eecf 100644 --- a/docs/en/UI/AspNetCore/Data-Tables.md +++ b/docs/en/UI/AspNetCore/Data-Tables.md @@ -101,7 +101,7 @@ Here, the all configuration options; DataTables.Net has its own expected data format while getting results of an AJAX call to the server to get the table data. They are especially related how paging and sorting parameters are sent and received. ABP Framework also offers its own conventions for the client-server [AJAX](JavaScript-API/Ajax.md) communication. -The `abp.libs.datatables.createAjax` method (used in the example above) adapts request and response data format and perfectly works with the [Dynamic JavaScript Client Proxy](Dynamic-JavaScript-Client-Proxies.md) system. +The `abp.libs.datatables.createAjax` method (used in the example above) adapts request and response data format and perfectly works with the [Dynamic JavaScript Client Proxy](Dynamic-JavaScript-Proxies.md) system. This works automatically, so most of the times you don't need to know how it works. See the [DTO document](../../Data-Transfer-Objects.md) if you want to learn more about `IPagedAndSortedResultRequest`, `IPagedResult` and other standard interfaces and base DTO classes those are used in client to server communication. diff --git a/docs/en/UI/AspNetCore/Entity-Action-Extensions.md b/docs/en/UI/AspNetCore/Entity-Action-Extensions.md new file mode 100644 index 0000000000..f6e865375d --- /dev/null +++ b/docs/en/UI/AspNetCore/Entity-Action-Extensions.md @@ -0,0 +1,108 @@ +# Entity Action Extensions for ASP.NET Core UI + +## Introduction + +Entity action extension system allows you to add a **new action** to the action menu for an entity. A **Click Me** action was added to the *User Management* page below: + +![user-action-extension-click-me](../../images/user-action-extension-click-me.png) + +You can take any action (open a modal, make an HTTP API call, redirect to another page... etc) by writing your custom code. You can access to the current entity in your code. + +## How to Set Up + +In this example, we will add a "Click Me!" action and execute a JavaScript code for the user management page of the [Identity Module](../../Modules/Identity.md). + +### Create a JavaScript File + +First, add a new JavaScript file to your solution. We added inside the `/Pages/Identity/Users` folder of the `.Web` project: + +![user-action-extension-on-solution](../../images/user-action-extension-on-solution.png) + +Here, the content of this JavaScript file: + +```js +var clickMeAction = { + text: 'Click Me!', + action: function(data) { + //TODO: Write your custom code + alert(data.record.userName); + } +}; + +abp.ui.extensions.entityActions + .get('identity.user') + .addContributor(function(actionList) { + actionList.addTail(clickMeAction); + }); +``` + +In the `action` function, you can do anything you need. See the API section for a detailed usage. + +### Add the File to the User Management Page + +Then you need to add this JavaScript file to the user management page. You can take the power of the [Bundling & Minification System](Bundling-Minification.md). + +Write the following code inside the `ConfigureServices` of your module class: + +```csharp +Configure(options => +{ + options.ScriptBundles.Configure( + typeof(Volo.Abp.Identity.Web.Pages.Identity.Users.IndexModel).FullName, + bundleConfiguration => + { + bundleConfiguration.AddFiles( + "/Pages/Identity/Users/my-user-extensions.js" + ); + }); +}); +``` + +This configuration adds `my-user-extensions.js` to the user management page of the Identity Module. `typeof(Volo.Abp.Identity.Web.Pages.Identity.Users.IndexModel).FullName` is the name of the bundle in the user management page. This is a common convention used for all the ABP Commercial modules. + +That's all. Run your application to see the result. + +## API + +This section explains details of the `abp.ui.extensions.entityActions` JavaScript API. + +### abp.ui.extensions.entityActions.get(entityName) + +This method is used to access the entity actions of a specific module. It takes one parameter: + +* **entityName**: The name of the entity defined by the related module. + +### abp.ui.extensions.entityActions.get(entityName).actions + +The `actions` property is used to retrieve a [doubly linked list](../Common/Utils/Linked-List.md) of previously defined actions for an entity. All contributors are executed in order to prepare the final actions list. This is normally called by the modules to show the actions in the grid. However, you can use it if you are building your own extensible UIs. + +### abp.ui.extensions.entityActions.get(entityName).addContributor(contributeCallback) + +The `addContributor` method covers all scenarios, e.g. you want to add your action in a different position in the list, change or remove an existing action item. `addContributor` with the following parameter: + +* **contributeCallback**: A callback function that is called whenever the action list should be created. You can freely modify the action list inside this callback method. + +#### Example + +```js +var clickMe2Action = { + text: 'Click Me 2!', + icon: 'fas fa-hand-point-right', + action: function(data) { + //TODO: Write your custom code + alert(data.record.userName); + } +}; + +abp.ui.extensions.entityActions + .get('identity.user') + .addContributor(function(actionList) { + // Remove an item from actionList + actionList.dropHead(); + + // Add the new item to the actionList + actionList.addHead(clickMe2Action); + }); +``` + +> `actionList` is [linked list](../Common/Utils/Linked-List.md). You can use its methods to build a list of columns however you need. diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Features.md b/docs/en/UI/AspNetCore/JavaScript-API/Features.md index e3cd2be445..8d58347f49 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Features.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Features.md @@ -6,10 +6,24 @@ ## Basic Usage -`abp.features.values` can be used to access to the all feature values. - ````js -var excelExportFeatureValue = abp.features.values["ExportingToExcel"]; +//Gets a value as string. +var value = abp.features.get('ExportingToExcel'); + +//Check the feature is enabled +var enabled = abp.features.isEnabled('ExportingToExcel.Enabled'); ```` -Then you can check the value of the feature to perform your logic. \ No newline at end of file +## All Values + +`abp.features.values` can be used to access to the all feature values. + +An example value of this object is shown below: + +````js +{ + Identity.TwoFactor: "Optional", + ExportingToExcel.Enabled: "true", + ... +} +```` \ No newline at end of file diff --git a/docs/en/UI/AspNetCore/Navigation-Menu.md b/docs/en/UI/AspNetCore/Navigation-Menu.md index 13a6e1678c..7a8fe31e3e 100644 --- a/docs/en/UI/AspNetCore/Navigation-Menu.md +++ b/docs/en/UI/AspNetCore/Navigation-Menu.md @@ -13,6 +13,8 @@ So, ABP Framework **provides a menu infrastructure** where; In order to add menu items (or manipulate the existing items) you need to create a class implementing the `IMenuContributor` interface. +> The [application startup template](../../Startup-Templates/Application.md) already contains an implementation of the `IMenuContributor`. So, you can add items inside that class instead of creating a new one. + **Example: Add a *CRM* menu item with *Customers* and *Orders* sub menu items** ```csharp @@ -66,6 +68,16 @@ Configure(options => }); ```` +This example uses some localization keys as display names those should be defined in the localization file: + +````json +"Menu:CRM": "CRM", +"Menu:Orders": "Orders", +"Menu:Customers": "Customers" +```` + +See the [localization document](../../Localization.md) to learn more about the localization. + When you run the application, you will see the menu items added to the main menu: ![nav-main-menu](../../images/nav-main-menu.png) @@ -89,7 +101,7 @@ There are more options of a menu item (the constructor of the `ApplicationMenuIt * `icon` (`string`): An icon name. Free [Font Awesome](https://fontawesome.com/) icon classes are supported out of the box. Example: `fa fa-book`. You can use any CSS font icon class as long as you include the necessary CSS files to your application. * `order` (`int`): The order of the menu item. Default value is `1000`. Items are sorted by the adding order unless you specify an order value. * `customData` (`object`): A custom object that you can associate to the menu item and use it while rendering the menu item. -* `target` (`string`): Target of the menu item. Can be `null` (default), "_blank", "_*self*", "_parent", "_*top*" or a frame name for web applications. +* `target` (`string`): Target of the menu item. Can be `null` (default), "\_*blank*", "\_*self*", "\_*parent*", "\_*top*" or a frame name for web applications. * `elementId` (`string`): Can be used to render the element with a specific HTML `id` attribute. * `cssClass` (`string`): Additional string classes for the menu item. @@ -97,7 +109,7 @@ There are more options of a menu item (the constructor of the `ApplicationMenuIt As seen above, a menu contributor contributes to the menu dynamically. So, you can perform any custom logic or get menu items from any source. -One use case is the [authorization](Authorization.md). You typically want to add menu items by checking a permission. +One use case is the [authorization](../../Authorization.md). You typically want to add menu items by checking a permission. **Example: Check if the current user has a permission** diff --git a/docs/en/UI/AspNetCore/Overall.md b/docs/en/UI/AspNetCore/Overall.md index a499cd93a3..8cd9dd3f5e 100644 --- a/docs/en/UI/AspNetCore/Overall.md +++ b/docs/en/UI/AspNetCore/Overall.md @@ -50,7 +50,7 @@ There are a set of standard JavaScript/CSS libraries that comes pre-installed an - [FontAwesome](https://fontawesome.com/) as the fundamental CSS font library. - [SweetAlert](https://sweetalert.js.org/) to show fancy alert message and confirmation dialogs. - [Toastr](https://github.com/CodeSeven/toastr) to show toast notifications. -- [Lodesh](https://lodash.com/) as a utility library. +- [Lodash](https://lodash.com/) as a utility library. - [Luxon](https://moment.github.io/luxon/) for date/time operations. - [JQuery Form](https://github.com/jquery-form/form) for AJAX forms. - [bootstrap-datepicker](https://github.com/uxsolutions/bootstrap-datepicker) to show date pickers. @@ -156,4 +156,4 @@ ABP Framework provides a lot of built-in solutions to common application require ## Customization -There are a lot of ways to customize the theme and the UIs of the pre-built modules. You can override components, pages, static resources, bundles and more. See the [User Interface Customization Guide](Customization-User-Interface.md). \ No newline at end of file +There are a lot of ways to customize the theme and the UIs of the pre-built modules. You can override components, pages, static resources, bundles and more. See the [User Interface Customization Guide](Customization-User-Interface.md). diff --git a/docs/en/UI/AspNetCore/Tag-Helpers/Index.md b/docs/en/UI/AspNetCore/Tag-Helpers/Index.md index f85edb5142..5b16d9ccdc 100644 --- a/docs/en/UI/AspNetCore/Tag-Helpers/Index.md +++ b/docs/en/UI/AspNetCore/Tag-Helpers/Index.md @@ -16,7 +16,7 @@ Here, the list of components those are wrapped by the ABP Framework: * [Badges](Badges.md) * [Blockquote](Blockquote.md) * [Borders](Borders.md) -* [Breadcrumb](Breadcrumb.md) +* [Breadcrumb](Breadcrumbs.md) * [Buttons](Buttons.md) * [Cards](Cards.md) * [Carousel](Carousel.md) diff --git a/docs/en/UI/AspNetCore/Theming.md b/docs/en/UI/AspNetCore/Theming.md index 8c680973b8..85acf65433 100644 --- a/docs/en/UI/AspNetCore/Theming.md +++ b/docs/en/UI/AspNetCore/Theming.md @@ -32,7 +32,7 @@ All the themes must depend on the [@abp/aspnetcore.mvc.ui.theme.shared](https:// * [Twitter Bootstrap](https://getbootstrap.com/) as the fundamental HTML/CSS framework. * [JQuery](https://jquery.com/) for DOM manipulation. * [DataTables.Net](https://datatables.net/) for data grids. -* [JQuery Validation](https://jqueryvalidation.org/) for client side & [unobtrusive](https://github.com/aspnet/jquery-validation-unobtrusive) validation +* [JQuery Validation](https://github.com/jquery-validation/jquery-validation) for client side & [unobtrusive](https://github.com/aspnet/jquery-validation-unobtrusive) validation * [FontAwesome](https://fontawesome.com/) as the fundamental CSS font library. * [SweetAlert](https://sweetalert.js.org/) to show fancy alert message and confirmation dialogs. * [Toastr](https://github.com/CodeSeven/toastr) to show toast notifications. diff --git a/docs/en/UI/Blazor/Authentication.md b/docs/en/UI/Blazor/Authentication.md new file mode 100644 index 0000000000..9dc34ebce5 --- /dev/null +++ b/docs/en/UI/Blazor/Authentication.md @@ -0,0 +1,11 @@ +# Blazor UI: Authentication + +The [application startup template](../../Startup-Templates/Application.md) is properly configured to use OpenId Connect to authenticate the user through the server side login form; + +* When the Blazor application needs to authenticate, it is redirected to the server side. +* Users can enter username & password to login if they already have an account. If not, they can use the register form to create a new user. They can also use forgot password and other features. The server side uses IdentityServer4 to handle the authentication. +* Finally, they are redirected back to the Blazor application to complete the login process. + +This is a typical and recommended approach to implement authentication in Single-Page Applications. The client side configuration is done in the startup template, so you can change it. + +See the [Blazor Security document](https://docs.microsoft.com/en-us/aspnet/core/blazor/security) to understand and customize the authentication process. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Authorization.md b/docs/en/UI/Blazor/Authorization.md new file mode 100644 index 0000000000..7325c8e57b --- /dev/null +++ b/docs/en/UI/Blazor/Authorization.md @@ -0,0 +1,75 @@ +# Blazor UI: Authorization + +Blazor applications can use the same authorization system and permissions defined in the server side. + +> This document is only for authorizing on the Blazor UI. See the [Server Side Authorization](../../Authorization.md) to learn how to define permissions and control the authorization system. + +## Basic Usage + +> ABP Framework is **100% compatible** with the Authorization infrastructure provided by the Blazor. See the [Blazor Security Document](https://docs.microsoft.com/en-us/aspnet/core/blazor/security/) to learn all authorization options. This section **only shows some common scenarios**. + +### Authorize Attribute + +`[Authorize]` attribute can be used to show a page only to the authenticated users. + +````csharp +@page "/" +@attribute [Authorize] + +You can only see this if you're signed in. +```` + +The `[Authorize]` attribute also supports role-based or policy-based authorization. For example, you can check permissions defined in the server side: + +````csharp +@page "/" +@attribute [Authorize("MyPermission")] + +You can only see this if you have the necessary permission. +```` + +### AuthorizeView + +`AuthorizeView` component can be used in a page/component to conditionally render a part of the content: + +````html + +

You can only see this if you satisfy the "MyPermission" policy.

+
+```` + +### IAuthorizationService + +`IAuthorizationService` can be injected and used to programmatically check permissions: + +````csharp +public partial class Index +{ + protected override async Task OnInitializedAsync() + { + if (await AuthorizationService.IsGrantedAsync("MyPermission")) + { + //... + } + } +} +```` + +If your component directly or indirectly inherits from the `AbpComponentBase`, `AuthorizationService` becomes pre-injected and ready to use. If not, you can always [inject](../../Dependency-Injection.md) the `IAuthorizationService` yourself. + +`IAuthorizationService` can also be used in the view side where `AuthorizeView` component is not enough. + +There are some useful extension methods for the `IAuthorizationService`: + +* `IsGrantedAsync` simply returns `true` or `false` for the given policy/permission. +* `CheckAsync` checks and throws `AbpAuthorizationException` if given policy/permission hasn't granted. You don't have to handle these kind of exceptions since ABP Framework automatically [handles errors](Error-Handling.md). +* `AuthorizeAsync` returns `AuthorizationResult` as the standard way provided by the ASP.NET Core authorization system. + +> See the [Blazor Security Document](https://docs.microsoft.com/en-us/aspnet/core/blazor/security/) to learn all authorization options + +## See Also + +* [Authorization](../../Authorization.md) (server side) +* [Blazor Security](https://docs.microsoft.com/en-us/aspnet/core/blazor/security/) (Microsoft documentation) +* [ICurrentUser Service](CurrentUser.md) + diff --git a/docs/en/UI/Blazor/Basic-Theme.md b/docs/en/UI/Blazor/Basic-Theme.md new file mode 100644 index 0000000000..926d15cf11 --- /dev/null +++ b/docs/en/UI/Blazor/Basic-Theme.md @@ -0,0 +1,57 @@ +# Blazor UI: Basic Theme + +The Basic Theme is a theme implementation for the Blazor UI. It is a minimalist theme that doesn't add any styling on top of the plain [Bootstrap](https://getbootstrap.com/). You can take the Basic Theme as the **base theme** and build your own theme or styling on top of it. See the *Customization* section. + +> If you are looking for a professional, enterprise ready theme, you can check the [Lepton Theme](https://commercial.abp.io/themes), which is a part of the [ABP Commercial](https://commercial.abp.io/). + +> See the [Theming document](Theming.md) to learn about themes. + +## Installation + +**This theme is already installed** when you create a new solution using the [startup templates](../../Startup-Templates/Index.md). If you need to manually install it, follow the steps below: + +* Install the [Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme) NuGet package to your web project. +* Add `AbpAspNetCoreComponentsWebAssemblyBasicThemeModule` into the `[DependsOn(...)]` attribute for your [module class](../../Module-Development-Basics.md) in the your Blazor UI project. +* Use `Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic.App` as the root component of your application in the `ConfigureServices` method of your module: + +````csharp +var builder = context.Services.GetSingletonInstance(); +builder.RootComponents.Add("#ApplicationContainer"); +```` + +`#ApplicationContainer` is a selector (like `
Loading...
`) in the `index.html`. + +## The Layout + +![basic-theme-application-layout](../../images/basic-theme-application-layout.png) + +Application Layout implements the following parts, in addition to the common parts mentioned above; + +* [Branding](Branding.md) Area +* Main [Menu](Navigation-Menu.md) +* Main [Toolbar](Toolbars.md) with Language Selection & User Menu +* [Page Alerts](Page-Alerts.md) + +## Customization + +You have two options two customize this theme: + +### Overriding Styles / Components + +In this approach, you continue to use the the theme as NuGet and NPM packages and customize the parts you need to. There are several ways to customize it; + +#### Override the Styles + +You can simply override the styles in the Global Styles file of your application. + +#### Override the Components + +See the [Customization / Overriding Components](Customization-Overriding-Components.md) to learn how you can replace components, customize and extend the user interface. + +### Copy & Customize + +You can download the [source code](https://github.com/abpframework/abp/tree/dev/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme) of the Basic Theme, copy the project content into your solution, re-arrange the package/module dependencies (see the Installation section above to understand how it was installed to the project) and freely customize the theme based on your application requirements. + +## See Also + +* [Theming](Theming.md) \ No newline at end of file diff --git a/docs/en/UI/Blazor/Branding.md b/docs/en/UI/Blazor/Branding.md new file mode 100644 index 0000000000..94bcb2bad5 --- /dev/null +++ b/docs/en/UI/Blazor/Branding.md @@ -0,0 +1,37 @@ +# Blazor UI: Branding + +## IBrandingProvider + +`IBrandingProvider` is a simple interface that is used to show the application name and logo on the layout. + +The screenshot below shows *MyProject* as the application name: + +![branding-nobrand](../../images/branding-nobrand.png) + +You can implement the `IBrandingProvider` interface or inherit from the `DefaultBrandingProvider` to set the application name: + +````csharp +using Volo.Abp.DependencyInjection; +using Volo.Abp.Ui.Branding; + +namespace MyCompanyName.MyProjectName.Blazor +{ + [Dependency(ReplaceServices = true)] + public class MyProjectNameBrandingProvider : DefaultBrandingProvider + { + public override string AppName => "Book Store"; + } +} +```` + +The result will be like shown below: + +![branding-appname](../../images/branding-appname.png) + +`IBrandingProvider` has the following properties: + +* `AppName`: The application name. +* `LogoUrl`: A URL to show the application logo. +* `LogoReverseUrl`: A URL to show the application logo on a reverse color theme (dark, for example). + +> **Tip**: `IBrandingProvider` is used in every page refresh. For a multi-tenant application, you can return a tenant specific application name to customize it per tenant. diff --git a/docs/en/UI/Blazor/CurrentTenant.md b/docs/en/UI/Blazor/CurrentTenant.md new file mode 100644 index 0000000000..0ccee9966c --- /dev/null +++ b/docs/en/UI/Blazor/CurrentTenant.md @@ -0,0 +1,23 @@ +# Blazor UI: Current Tenant + +`ICurrentTenant` service can be used to get information about the current tenant in a [multi-tenant](../../Multi-Tenancy.md) application. `ICurrentTenant` defines the following properties; + +* `Id` (`Guid`): Id of the current tenant. Can be `null` if the current user is a host user or the tenant could not be determined. +* `Name` (`string`): Name of the current tenant. Can be `null` if the current user is a host user or the tenant could not be determined. +* `IsAvailable` (`bool`): Returns `true` if the `Id` is not `null`. + +**Example: Show the current tenant name on a page** + +````csharp +@page "/" +@using Volo.Abp.MultiTenancy +@inject ICurrentTenant CurrentTenant +@if (CurrentTenant.IsAvailable) +{ +

Current tenant name: @CurrentTenant.Name

+} +```` + +## See Also + +* [Multi-Tenancy](../../Multi-Tenancy.md) \ No newline at end of file diff --git a/docs/en/UI/Blazor/CurrentUser.md b/docs/en/UI/Blazor/CurrentUser.md new file mode 100644 index 0000000000..d0d761420a --- /dev/null +++ b/docs/en/UI/Blazor/CurrentUser.md @@ -0,0 +1,22 @@ +# Blazor UI: Current User + +`ICurrentUser` service is used to obtain information about the currently authenticated user. Inject the `ICurrentUser` into any component/page and use its properties and methods. + +**Example: Show username & email on a page** + +````csharp +@page "/" +@using Volo.Abp.Users +@inject ICurrentUser CurrentUser +@if (CurrentUser.IsAuthenticated) +{ +

Welcome @CurrentUser.UserName

+} +```` + +> If you (directly or indirectly) derived your component from the `AbpComponentBase`, you can directly use the base `CurrentUser` property. + +`ICurrentUser` provides `Id`, `Name`, `SurName`, `Email`, `Roles` and some other properties. + +> See the [Server Side Current User](../../CurrentUser) service for more information. + diff --git a/docs/en/UI/Blazor/Customization-Overriding-Components.md b/docs/en/UI/Blazor/Customization-Overriding-Components.md new file mode 100644 index 0000000000..995213f9e7 --- /dev/null +++ b/docs/en/UI/Blazor/Customization-Overriding-Components.md @@ -0,0 +1,86 @@ +# Blazor UI: Customization / Overriding Components + +This document explains how to override the user interface of a depended [application module](../../Modules/Index.md) or [theme](Theming.md) for Blazor applications. + +## Overriding a Razor Component + +The ABP Framework, pre-built themes and modules define some **re-usable razor components and pages**. These pages and components can be replaced by your application or module. + +> Since pages are just the razor components, the same principle is valid for pages too. + +### Example: Replacing the Branding Area + +The screenshot below was taken from the [Basic Theme](Basic-Theme.md) comes with the application startup template. + +![bookstore-brand-area-highlighted](../../images/bookstore-brand-area-highlighted.png) + +The [Basic Theme](Basic-Theme.md) defines some razor components for the layout. For example, the highlighted area with the red rectangle above is called *Branding* component. You probably want to customize this component by adding your **own application logo**. Let's see how to do it. + +First, create your logo and place under a folder in your web application. We used `wwwroot/bookstore-logo.png` path: + +![bookstore-logo-blazor](../../images/bookstore-logo-blazor.png) + +The next step is to create a razor component, like `MyBlazor.razor`, in your application: + +![bookstore-logo-blazor](../../images/bookstore-branding-blazor.png) + +The content of the `MyBlazor.razor` is shown below: + +````html +@using Volo.Abp.DependencyInjection +@using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic +@inherits Branding +@attribute [ExposeServices(typeof(Branding))] +@attribute [Dependency(ReplaceServices = true)] + + + +```` + +Let's explain the code: + +* `@inherits Branding` line inherits the Branding component defined by the [Basic Theme](Basic-Theme.md) (in the `Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic` namespace). +* `@attribute [ExposeServices(typeof(Branding))]` registers this service (component) to [dependency injection](../../Dependency-Injection.md) for the `Branding` service (component). +* `@attribute [Dependency(ReplaceServices = true)]` replaces the `Branding` class (component) with this new `MyBranding` class (component). +* The rest of the code is related the content and styling of the component. + +Now, you can run the application to see the result: + +![bookstore-added-logo](../../images/bookstore-added-logo.png) + +> Since the component inherits from the component it is replacing, you can use all the non-private fields/properties/methods of the base component in the derived component. + +### Example: Replacing with the Code Behind File + +If you prefer to use code-behind file for the C# code of your component, you can use the attributes in the C# side. + +**MyBlazor.razor** + +````html +@using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic +@inherits Branding + + + +```` + +**MyBlazor.razor.cs** + +````csharp +using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic; +using Volo.Abp.DependencyInjection; + +namespace MyProject.Blazor.Components +{ + [ExposeServices(typeof(Branding))] + [Dependency(ReplaceServices = true)] + public partial class MyBranding + { + + } +} +```` + +## Theming + +The [Theming](Theming.md) system allows you to build your own theme. You can create your theme from scratch or get the [Basic Theme](Basic-Theme.md) and change however you like. diff --git a/docs/en/UI/Blazor/Error-Handling.md b/docs/en/UI/Blazor/Error-Handling.md new file mode 100644 index 0000000000..f43456e3a7 --- /dev/null +++ b/docs/en/UI/Blazor/Error-Handling.md @@ -0,0 +1,62 @@ +# Blazor UI: Error Handling + +Blazor, by default, shows a yellow line at the bottom of the page if any unhandled exception occurs. However, this is not useful in a real application. + +ABP provides an automatic error handling system for the Blazor UI. + +* Handles all unhandled exceptions and shows nice and useful messages to the user. +* It distinguishes different kind of exceptions. Hides internal/technical error details from the user (shows a generic error message in these cases). +* It is well integrated to the [server side exception handling](../../Exception-Handling.md) system. + +## Basic Usage + +There are different type of `Exception` classes handled differently by the ABP Framework. + +### UserFriendlyException + +`UserFriendlyException` is a special type of exception. You can directly show a error message dialog to the user by throwing such an exception. + +**Example** + +````csharp +@page "/" +@using Volo.Abp + + + +@code +{ + private void TestException() + { + throw new UserFriendlyException("A user friendly error message!"); + } +} +```` + +ABP automatically handle the exception and show an error message to the user: + +![blazor-user-friendly-exception](../../images/blazor-user-friendly-exception.png) + +> You can derive from `UserFriendlyException` or directly implement `IUserFriendlyException` interface to create your own `Exception` class if you need. + +> You can use the [localization system](Localization.md) to show localized error messages. + +### BusinessException and Other Exception Types + +See the [exception handling document](../../Exception-Handling.md) to understand different kind of Exception class and interfaces and other capabilities of the Exception Handling system. + +## Generic Errors + +If the thrown `Exception` is not a special type, it is considered as generic error and a generic error message is shown to the user: + +![blazor-generic-exception-message](../../images/blazor-generic-exception-message.png) + +> All error details (including stack trace) are still written in the browser's console. + +## Server Side Errors + +Errors (like Validation, Authorization and User Friendly Errors) sent by the server are processed as you expect and properly shown to the user. So, error handling system works end to end without need to manually handle exceptions or manually transfer server-to-client error messages. + +## See Also + +* [Exception Handling System](../../Exception-Handling.md) \ No newline at end of file diff --git a/docs/en/UI/Blazor/Global-Scripts-Styles.md b/docs/en/UI/Blazor/Global-Scripts-Styles.md new file mode 100644 index 0000000000..a9a69c76d0 --- /dev/null +++ b/docs/en/UI/Blazor/Global-Scripts-Styles.md @@ -0,0 +1,38 @@ +# Blazor UI: Managing Global Scripts & Styles + +Some modules may require additional styles or scripts that need to be referenced in **index.html** file. It's not easy to find and update these types of references in Blazor apps. ABP offers a simple, powerful, and modular way to manage global style and scripts in Blazor apps. + +To update script & style references without worrying about dependencies, ordering, etc in a project, you can use the [bundle command](../../CLI.md#bundle). + +You can also add custom styles and scripts and let ABP manage them for you. In your Blazor project, you can create a class implementing `IBundleContributor` interface. + +`IBundleContributor` interface contains two methods. + +* `AddScripts(...)` +* `AddStyles(...)` + +Both methods get `BundleContext` as a parameter. You can add scripts and styles to the `BundleContext` and run [bundle command](../../CLI.md#bundle). Bundle command detects custom styles and scripts with module dependencies and updates `index.html` file. + +## Example Usage +```csharp +namespace MyProject.Blazor +{ + public class MyProjectBundleContributor : IBundleContributor + { + public void AddScripts(BundleContext context) + { + context.Add("site.js"); + } + + public void AddStyles(BundleContext context) + { + context.Add("main.css"); + context.Add("custom-styles.css"); + } + } +} +``` + +> There is a BundleContributor class implementing `IBundleContributor` interface coming by default with the startup templates. So, most of the time, you don't need to add it manually. + +> Bundle command adds style and script references individually. Bundling and minification support will be added to incoming releases. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Localization.md b/docs/en/UI/Blazor/Localization.md index 23b31a5a24..d42249388e 100644 --- a/docs/en/UI/Blazor/Localization.md +++ b/docs/en/UI/Blazor/Localization.md @@ -1,3 +1,78 @@ -# Blazor: Localization +# Blazor UI: Localization -Blazor applications can reuse the same `IStringLocalizer` service that is explained in the [localization document](../../Localization.md). All the localization resources and texts available in the server side are usable in the Blazor application. \ No newline at end of file +Blazor applications can reuse the same `IStringLocalizer` service that is explained in the [localization document](../../Localization.md). + +All the localization resources and texts available in the server side are usable in the Blazor application. + +## IStringLocalizer + +`IStringLocalizer` (`T` is the localization resource class) can be injected in any service or component to use the localization service. + +### Razor Components + +Use `@inject IStringLocalizer` to use the localization in a razor component. + +**Example: Localization in a Razor Component** + +````csharp +@page "/" +@using MyCompanyName.MyProjectName.Localization +@using Microsoft.Extensions.Localization +@inject IStringLocalizer L + +

+ @L["LongWelcomeMessage"] +

+```` + +> `L` is a name that we love and use as the name of a `IStringLocalizer` instance, while you can give any name. + +#### The AbpComponentBase + +`AbpComponentBase` is a useful base class that you can derive the components from. It has some useful properties/methods you typically need in a component. + +The `AbpComponentBase` already defines a base `L` property (of type `IStringLocalizer`). It only requires to set the resource type (in the constructor of the derived class). If you created your application from the ABP's application startup template, then you should have a *YourProjectComponentBase* class in the Blazor project. Inherit components from this class to have the localizer pre-injected. + +**Example: Derive from the base component class** + +````csharp +@page "/" +@inherits MyProjectNameComponentBase + +

+ @L["LongWelcomeMessage"] +

+```` + +### Other Services + +`IStringLocalizer` can be injected into any service. + +**Example** + +````csharp +public class MyService : ITransientDependency +{ + private readonly IStringLocalizer _localizer; + + public MyService(IStringLocalizer localizer) + { + _localizer = localizer; + } + + public void Foo() + { + var str = _localizer["HelloWorld"]; + } +} +```` + +### Format Arguments + +Format arguments can be passed after the localization key. If your message is `Hello {0}, welcome!`, then you can pass the `{0}` argument to the localizer like `_localizer["HelloMessage", "John"]`. + +> Refer to the [Microsoft's localization documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization) for details about using the localization. + +## See Also + +* [Localization](../../Localization.md) \ No newline at end of file diff --git a/docs/en/UI/Blazor/Message.md b/docs/en/UI/Blazor/Message.md index 8373bd1d82..a2faee2548 100644 --- a/docs/en/UI/Blazor/Message.md +++ b/docs/en/UI/Blazor/Message.md @@ -1,3 +1,129 @@ -# Blazor: UI Message Service +# Blazor UI: Message Service -TODO \ No newline at end of file +UI message service is used to show nice-looking messages to the user as a blocking dialog. + +## Quick Example + +Simply [inject](../../Dependency-Injection.md) `IUiMessageService` to your page or component and call the `Success` method to show a success message. + +```csharp +namespace MyProject.Blazor.Pages +{ + public partial class Index + { + private readonly IUiMessageService _uiMessageService; + + public Index(IUiMessageService uiMessageService) + { + _uiMessageService = uiMessageService; + } + + public async Task SaveAsync() + { + await _uiMessageService.Success( + "Your changes have been successfully saved!", + "Congratulations"); + } + } +} +``` + +It will show a dialog on the UI: + +![blazor-message-success](../../images/blazor-message-success.png) + +If you inherit your page or component from the `AbpComponentBase` class, you can use the `Message` property to access the `IUiMessageService` as a pre-injected property. + +```csharp +namespace MyProject.Blazor.Pages +{ + public partial class Index : AbpComponentBase + { + public async Task SaveAsync() + { + await Message.Success( + "Your changes have been successfully saved!", + "Congratulations"); + } + } +} +``` +> You typically use `@inherits AbpComponentBase` in the `.razor` file to inherit from the `AbpComponentBase`, instead of inheriting in the code behind file. + +## Informative Messages + +There are four types of informative message functions: + +* `Info(...)` +* `Success(...)` +* `Warn(...)` +* `Error(...)` + +All of these methods get three parameters: + +* `message`: The message (`string`) to be shown. +* `title`: An optional (`string`) title. +* `options`: An optional (`Action`) to configure UI message options. + +**Example: Show an error message** + +````csharp +_uiMessageService.Error('Your credit card number is not valid!'); +```` + +![blazor-message-success](../../images/blazor-message-error.png) + + +## Confirmation Message + +`IUiMessageService.Confirm(...)` method can be used to get a confirmation from the user. + +**Example** + +Use the following code to get a confirmation result from the user: + +```csharp +public async Task DeleteAsync() +{ + var confirmed = await _uiMessageService.Confirm("Are you sure to delete the 'admin' role?"); + if(confirmed) + { + //Delete the 'admin' role here. + } +} +``` + +The resulting UI will be like shown below: + +![blazor-message-confirm](../../images/blazor-message-confirm.png) + +If the user has clicked the `Yes` button, the `Confirm` method's return value will be `true`. + +## Configuration + +It is easy to change default message options if you like to it per message. Provide an `action` to the `options` parameter as shown below. + +```csharp +await _uiMessageService.Success( + "Your changes have been successfully saved!", + "Congratulations", + (options) => + { + options.MessageIcon = "msg-icon-new"; + options.CenterMessage = false; + }); +``` + +List of the options that you can change by providing the `action` parameter. + +* `CenterMessage` : (Default: true) If true, the message dialogue will be centered on the screen. +* `ShowMessageIcon` : (Default: true) If true, the message dialogue will show the large icon for the current message type. +* `MessageIcon` : Overrides the build-in message icon. +* `OkButtonText` : Custom text for the OK button. +* `OkButtonIcon` : Custom icon for the OK button. +* `ConfirmButtonText` : Custom text for the Confirmation button. +* `ConfirmButtonIcon` : Custom icon for the Confirmation button. +* `CancelButtonText` : Custom text for the Cancel button. +* `CancelButtonIcon` : Custom icon for the Cancel button. + +> "Confirm", "Cancel" and "Yes" texts are automatically localized based on the current language. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Navigation-Menu.md b/docs/en/UI/Blazor/Navigation-Menu.md new file mode 100644 index 0000000000..331de7a4cb --- /dev/null +++ b/docs/en/UI/Blazor/Navigation-Menu.md @@ -0,0 +1,207 @@ +# Blazor UI: Navigation / Menu + +Every application has a main menu to allow users to navigate to pages/screens of the application. Some applications may contain more than one menu in different sections of the UI. + +ABP Framework is a [modular](../../Module-Development-Basics.md) application development framework. **Every module may need to add items to the menu**. + +So, ABP Framework **provides a menu infrastructure** where; + +* The application or the modules can add items to a menu, without knowing how the menu is rendered. +* The [theme](Theming.md) properly renders the menu. + +## Adding Menu Items + +In order to add menu items (or manipulate the existing items) you need to create a class implementing the `IMenuContributor` interface. + +> The [application startup template](../../Startup-Templates/Application.md) already contains an implementation of the `IMenuContributor`. So, you can add items inside that class instead of creating a new one. + +**Example: Add a *CRM* menu item with *Customers* and *Orders* sub menu items** + +```csharp +using System.Threading.Tasks; +using MyProject.Localization; +using Volo.Abp.UI.Navigation; + +namespace MyProject.Web.Menus +{ + public class MyProjectMenuContributor : IMenuContributor + { + public async Task ConfigureMenuAsync(MenuConfigurationContext context) + { + if (context.Menu.Name == StandardMenus.Main) + { + await ConfigureMainMenuAsync(context); + } + } + + private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + var l = context.GetLocalizer(); + + context.Menu.AddItem( + new ApplicationMenuItem("MyProject.Crm", l["Menu:CRM"]) + .AddItem(new ApplicationMenuItem( + name: "MyProject.Crm.Customers", + displayName: l["Menu:Customers"], + url: "/crm/customers") + ).AddItem(new ApplicationMenuItem( + name: "MyProject.Crm.Orders", + displayName: l["Menu:Orders"], + url: "/crm/orders") + ) + ); + } + } +} +``` + +* This example adds items only to the main menu (`StandardMenus.Main`: see the *Standard Menus* section below). +* It gets a `IStringLocalizer` from `context` to [localize](../../Localization.md) the display names of the menu items. +* Adds the Customers and Orders as children of the CRM menu. + +Once you create a menu contributor, you need to add it to the `AbpNavigationOptions` in the `ConfigureServices` method of your module: + +````csharp +Configure(options => +{ + options.MenuContributors.Add(new MyProjectMenuContributor()); +}); +```` + +This example uses some localization keys as display names those should be defined in the localization file: + +````json +"Menu:CRM": "CRM", +"Menu:Orders": "Orders", +"Menu:Customers": "Customers" +```` + +See the [localization document](../../Localization.md) to learn more about the localization. + +When you run the application, you will see the menu items added to the main menu: + +![nav-main-menu](../../images/nav-main-menu.png) + +> The menu is rendered by the current UI [theme](Theming.md). So, the look of the main menu can be completely different based on your theme. + +Here, a few notes on the menu contributors; + +* ABP Framework calls the `ConfigureMenuAsync` method **whenever need to render** the menu. +* Every menu item can have **children**. So, you can add menu items with **unlimited depth** (however, your UI theme may not support unlimited depth). +* Only leaf menu items have `url`s normally. When you click to a parent menu, its sub menu is opened or closed, you don't navigate the `url` of a parent menu item. +* If a menu item has no children and has no `url` defined, then it is not rendered on the UI. This simplifies to authorize the menu items: You only authorize the child items (see the next section). If none of the children are authorized, then the parent automatically disappears. + +### Menu Item Properties + +There are more options of a menu item (the constructor of the `ApplicationMenuItem` class). Here, the list of all available options; + +* `name` (`string`, required): The **unique name** of the menu item. +* `displayName` (`string`, required): Display name/text of the menu item. You can [localize](../../Localization.md) this as shown before. +* `url` (`string`): The URL of the menu item. +* `icon` (`string`): An icon name. Free [Font Awesome](https://fontawesome.com/) icon classes are supported out of the box. Example: `fa fa-book`. You can use any CSS font icon class as long as you include the necessary CSS files to your application. +* `order` (`int`): The order of the menu item. Default value is `1000`. Items are sorted by the adding order unless you specify an order value. +* `customData` (`object`): A custom object that you can associate to the menu item and use it while rendering the menu item. +* `target` (`string`): Target of the menu item. Can be `null` (default), "\_*blank*", "\_*self*", "\_*parent*", "\_*top*" or a frame name for web applications. +* `elementId` (`string`): Can be used to render the element with a specific HTML `id` attribute. +* `cssClass` (`string`): Additional string classes for the menu item. + +### Authorization + +As seen above, a menu contributor contributes to the menu dynamically. So, you can perform any custom logic or get menu items from any source. + +One use case is the [authorization](Authorization.md). You typically want to add menu items by checking a permission. + +**Example: Check if the current user has a permission** + +````csharp +if (await context.IsGrantedAsync("MyPermissionName")) +{ + //...add menu items +} +```` + +> You can use `context.AuthorizationService` to directly access to the `IAuthorizationService`. + +### Resolving Dependencies + +`context.ServiceProvider` can be used to resolve any service dependency. + +**Example: Get a service** + +````csharp +var myService = context.ServiceProvider.GetRequiredService(); +//...use the service +```` + +> You don't need to care about releasing/disposing services. ABP Framework handles it. + +### The Administration Menu + +There is a special menu item in the menu menu that is added by the ABP Framework: The *Administration* menu. It is typically used by the pre-built admin [application modules](../../Modules/Index.md): + +![nav-main-menu-administration](../../images/nav-main-menu-administration.png) + +If you want to add menu items under the *Administration* menu item, you can use the `context.Menu.GetAdministration()` extension method: + +````csharp +context.Menu.GetAdministration().AddItem(...) +```` + +### Manipulating the Existing Menu Items + +ABP Framework executes the menu contributors by the [module dependency order](../../Module-Development-Basics.md). So, you can manipulate the menu items that your application or module (directly or indirectly) depends on. + +**Example: Set an icon for the `Users` menu item added by the [Identity Module](../../Modules/Identity.md)** + +````csharp +var userMenu = context.Menu.FindMenuItem(IdentityMenuNames.Users); +userMenu.Icon = "fa fa-users"; +```` + +> `context.Menu` gives you ability to access to all the menu items those have been added by the previous menu contributors. + +## Standard Menus + +A menu is a **named** component. An application may contain more than one menus with different, unique names. There are two pre-defined standard menus: + +* `Main`: The main menu of the application. Contains links to the page of the application. Defined as a constant: `Volo.Abp.UI.Navigation.StandardMenus.Main`. +* `User`: User profile menu. Defined as a constant: `Volo.Abp.UI.Navigation.StandardMenus.User`. + +The `Main` menu already covered above. The `User` menu is available when a user has logged in: + +![user-menu](../../images/user-menu.png) + +You can add items to the `User` menu by checking the `context.Menu.Name` as shown below: + +```csharp +if (context.Menu.Name == StandardMenus.User) +{ + //...add items +} +``` + +## IMenuManager + +`IMenuManager` is generally used by the UI [theme](Theming.md) to render the menu items on the UI. So, **you generally don't need to directly use** the `IMenuManager`. + +**Example: Get the Main Menu to render in a razor component** + +```csharp +// Code behind file of a razor component +public partial class NavMenu +{ + private readonly IMenuManager _menuManager; + + public NavMenu(IMenuManager menuManager) + { + _menuManager = menuManager; + } + + protected override async Task OnInitializedAsync() + { + var menu = await _menuManager.GetAsync(StandardMenus.Main); + //... + } +} +``` + diff --git a/docs/en/UI/Blazor/Notification.md b/docs/en/UI/Blazor/Notification.md index ef8945347b..24b589b75c 100644 --- a/docs/en/UI/Blazor/Notification.md +++ b/docs/en/UI/Blazor/Notification.md @@ -1,3 +1,103 @@ -# Blazor: Notification +# Blazor UI: Notification Service -`UiNotificationService` is used to show toastr style notifications on the user interface. The documentation is in progress... \ No newline at end of file +`IUiNotificationService` is used to show toast style notifications on the user interface. + +## Quick Example + +Simply [inject](../../Dependency-Injection.md) `IUiNotificationService` to your page or component and call the `Success` method to show a success message. + +```csharp +namespace MyProject.Blazor.Pages +{ + public partial class Index + { + private readonly IUiNotificationService _uiNotificationService; + + public Index(IUiNotificationService uiNotificationService) + { + _uiNotificationService = uiNotificationService; + } + + public async Task DeleteAsync() + { + await _uiNotificationService.Success( + "The product 'Acme Atom Re-Arranger' has been successfully deleted." + ); + } + } +} +``` + +![blazor-notification-sucess](../../images/blazor-notification-success.png) + +If you inherit your page or component from the `AbpComponentBase` class, you can use the the `Notify` property to access the `IUiNotificationService` as a pre-injected property. + +```csharp +namespace MyProject.Blazor.Pages +{ + public partial class Index : AbpComponentBase + { + public async Task DeleteAsync() + { + await Notify.Success( + "The product 'Acme Atom Re-Arranger' has been successfully deleted." + ); + } + } +} +``` + +> You typically use `@inherits AbpComponentBase` in the `.razor` file to inherit from the `AbpComponentBase`, instead of inheriting in the code behind file. + +## Notification Types + +There are four types of pre-defined notifications; + +* `Info(...)` +* `Success(...)` +* `Warn(...)` +* `Error(...)` + +All of the methods above gets the following parameters; + +* `message`: The message (`string`) to be shown. +* `title`: An optional (`string`) title. +* `options`: An optional (`Action`) to configure notification options. + +## Configuration + +### Per Notification + +It is easy to change default notification options if you like to customize it per notification. Provide an action to the `options` parameter as shown below: + +```csharp +await UiNotificationService.Success( + "The product 'Acme Atom Re-Arranger' has been successfully deleted.", + options: (options) => + { + options.OkButtonText = + LocalizableString.Create("CustomOK"); + }); +``` + +### Available Options + +Here, the list of all available options; + +* `OkButtonText` : Custom text for the OK button. +* `OkButtonIcon` : Custom icon for the OK button + +### Global Configuration + +You can also configure global notification options to control the it in a single point. Configure the `UiNotificationOptions` [options class](../../Options.md) in the `ConfigureServices` of your [module](../../Module-Development-Basics.md): + +````csharp +Configure(options => +{ + options.OkButtonText = LocalizableString.Create("CustomOK"); +}); +```` + +The same options are available here. + +> *Per notification* configuration overrides the default values. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Overall.md b/docs/en/UI/Blazor/Overall.md index 8af0e2fd0d..a249dd354b 100644 --- a/docs/en/UI/Blazor/Overall.md +++ b/docs/en/UI/Blazor/Overall.md @@ -1,8 +1,161 @@ -# Blazor UI for the ABP Framework +# Blazor UI: Overall -## Getting Started +## Introduction -You can follow the documents below to start with the ABP Framework and the Blazor UI: +[Blazor](https://docs.microsoft.com/en-us/aspnet/core/blazor/) is a framework for building interactive client-side web UI with .NET. It is promising for a .NET developer that you can create Single-Page Web Applications using C# and the Razor syntax. -* [Get started](https://docs.abp.io/en/abp/latest/Getting-Started?UI=Blazor) with the Blazor UI for the ABP Framework. -* [Web Application Development Tutorial](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=Blazor) with the Blazor UI. \ No newline at end of file +ABP provides infrastructure and integrations that make your Blazor development even easier, comfortable and enjoyable. + +This document provides an overview for the ABP Framework Blazor UI integration and highlights some major features. + +### Getting Started + +You can follow the documents below to start with the ABP Framework and the Blazor UI now: + +* [Get started](../../Getting-Started.md) with the Blazor UI for the ABP Framework. +* [Web Application Development Tutorial](../../Tutorials/Part-1.md) with the Blazor UI. + +## Modularity + +[Modularity](../../Module-Development-Basics.md) is one of the key goals of the ABP Framework. It is not different for the UI; It is possible to develop modular applications and reusable application modules with isolated and reusable UI pages and components. + +The [application startup template](../../Startup-Templates/Application.md) comes with some application modules pre-installed. These modules have their own UI pages embedded into their own NuGet packages. You don't see their code in your solution, but they work as expected on runtime. + +## Dynamic C# Client Proxies + +Dynamic C# Client Proxy system makes extremely easy to consume server side HTTP APIs from the UI. You just **inject** the [application service](../../Application-Services.md) **interface** and consume the remote APIs just like using local service method calls. + +**Example: Get list of books from server and list on the UI** + +````csharp +@page "/books" +@using Acme.BookStore.Books +@using Volo.Abp.Application.Dtos +@inject IBookAppService BookAppService + +
    + @foreach (var book in Books) + { +
  • + @book.Name (by @book.AuthorName) +
  • + } +
+ +@code { + private IReadOnlyList Books { get; set; } = new List(); + + protected override async Task OnInitializedAsync() + { + var result = await BookAppService.GetListAsync( + new PagedAndSortedResultRequestDto() + ); + + Books = result.Items; + } +} +```` + +* This razor component (page) uses `@inject IBookAppService BookAppService` to get a reference to the service proxy. +* It uses `BookAppService.GetListAsync` in the `OnInitializedAsync` and gets the list of the books, just like a regular C# method call. +* Finally, the page renders the books in a list on the UI. + +ABP Framework handles all the low level details for you, including a proper HTTP call, JSON serialization, exception handling and authentication. + +See the [Dynamic C# Client Proxies](../../API/Dynamic-CSharp-API-Clients.md) document for more. + +## Theming System + +ABP Framework provides a complete [Theming](Theming.md) system with the following goals: + +* Reusable [application modules](../../Modules/Index.md) are developed **theme-independent**, so they can work with any UI theme. +* UI theme is **decided by the final application**. +* The theme is distributed as NuGet package, so it is **easily upgradable**. +* The final application can **customize** the selected theme. + +### Current Themes + +Currently, two themes are **officially provided**: + +* The [Basic Theme](Basic-Theme.md) is the minimalist theme with the plain Bootstrap style. It is **open source and free**. +* The [Lepton Theme](https://commercial.abp.io/themes) is a **commercial** theme developed by the core ABP team and is a part of the [ABP Commercial](https://commercial.abp.io/) license. + +### Base Libraries + +There are a set of standard libraries that comes pre-installed and supported by all the themes: + +* [Twitter Bootstrap](https://getbootstrap.com/) as the fundamental HTML/CSS framework. +* [Blazorise](https://github.com/stsrki/Blazorise) as a component library that supports the Bootstrap and adds extra components like Data Grid and Tree. +* [FontAwesome](https://fontawesome.com/) as the fundamental CSS font library. +* [Flag Icon](https://github.com/lipis/flag-icon-css) as a library to show flags of countries. + +These libraries are selected as the base libraries and available to the applications and modules. + +> Bootstrap's JavaScript part is not used since the Blazorise library already provides the necessary functionalities to the Bootstrap components in a native way. + +### The Layout + +The themes provide the layout. So, you have a responsive layout with the standard features already implemented. The screenshot below has taken from the layout of the [Basic Theme](Basic-Theme.md): + +![basic-theme-application-layout](../../images/basic-theme-application-layout.png) + +See the [Theming](Theming.md) document for more layout options and other details. + +### Layout Parts + +A typical layout consists of multiple parts. The [Theming](Theming.md) system provides [menus](Navigation-Menu.md), [toolbars](Toolbars.md), [page alerts](Page-Alerts.md) and more to dynamically control the layout by your application and the modules you are using. + +## Global Styles & Scripts / Bundling & Minification + +ABP provides a standard way to manage the global script and style dependencies of an application. This is an essential feature for modularity since some modules may have such dependencies and they can declare dependencies in that way. + +See the [Managing Global Scripts & Styles](Global-Scripts-Styles.md) document. + +## Services + +ABP provides useful services that you can consume in your applications. Some of them are; + +* [IUiMessageService](Message.md) is used to show modal messages to the user. +* [IUiNotificationService](Notification.md) is used to show toast-style notifications. +* [IAlertManager](Page-Alerts.md) is used to show in-page alerts. +* [ISettingProvider](Settings.md) is used to access to the current setting values. +* `ICurrentUser` and `ICurrentTenant` is used to get information about the current user and the tenant. + +## Dependency Injection + +Razor components doesn't support [constructor injection](../../Dependency-Injection.md) by default. ABP makes possible to inject dependencies into the constructor of the code-behind file of a component. + +**Example: Constructor-inject a service in the code-behind file of a component** + +````csharp +using Microsoft.AspNetCore.Components; + +namespace MyProject.Blazor.Pages +{ + public partial class Index + { + private readonly NavigationManager _navigationManager; + + public Index(NavigationManager navigationManager) + { + _navigationManager = navigationManager; + } + } +} +```` + +ABP makes this possible by auto registering components to and resolving the component from the [Dependency Injection](../../Dependency-Injection.md) system. + +> You can still continue to use property injection and the standard `[Inject]` approach if you prefer. + +Resolving a component from the Dependency Injection system makes it possible to easily replace components of a depended module. + +## Error Handling + +Blazor, by default, shows a yellow line at the bottom of the page if any unhandled exception occurs. However, this is not useful in a real application. + +ABP provides an [automatic error handling system](Error-Handling.md) for the Blazor UI. + +## Customization + +While the theme and some modules come as NuGet packages, you can still replace/override and customize them on need. See the [Customization / Overriding Components](Customization-Overriding-Components.md) document. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Page-Alerts.md b/docs/en/UI/Blazor/Page-Alerts.md new file mode 100644 index 0000000000..cfac721572 --- /dev/null +++ b/docs/en/UI/Blazor/Page-Alerts.md @@ -0,0 +1,62 @@ +# Blazor UI: Page Alerts + +It is common to show error, warning or information alerts to inform the user. An example *Service Interruption* alert is shown below: + +![blazor-page-alert-example](../../images/blazor-page-alert-example.png) + +## Quick Example + +Simply [inject](../../Dependency-Injection.md) `IAlertManager` to your page or component and call the `Alerts.Warning` method to show a success message. + +```csharp +namespace MyProject.Blazor.Pages +{ + public partial class Index + { + private readonly IAlertManager _alertManager; + + public Index(IAlertManager alertManager) + { + this._alertManager = alertManager; + } + + protected override void OnInitialized() + { + _alertManager.Alerts.Warning( + "We will have a service interruption between 02:00 AM and 04:00 AM at October 23, 2023!", + "Service Interruption"); + base.OnInitialized(); + } + } +} +``` + +If you inherit your page or component from the `AbpComponentBase` class, you can use the `Alerts` property to add alerts. + +```csharp +namespace MyProject.Blazor.Pages +{ + public partial class Index : AbpComponentBase + { + protected override void OnInitialized() + { + Alerts.Warning( + "We will have a service interruption between 02:00 AM and 04:00 AM at October 23, 2023!", + "Service Interruption"); + base.OnInitialized(); + } + } +} +``` + +> You typically use `@inherits AbpComponentBase` in the `.razor` file to inherit from the `AbpComponentBase`, instead of inheriting in the code behind file. + +### Alert Types + +`Warning` is used to show a warning alert. Other common methods are `Info`, `Danger` and `Success`. + +Beside the standard methods, you can use the `Alerts.Add` method by passing an `AlertType` `enum` with one of these values: `Default`, `Primary`, `Secondary`, `Success`, `Danger`, `Warning`, `Info`, `Light`, `Dark`. + +### Dismissible + +All alert methods gets an optional `dismissible` parameter. Default value is `true` which makes the alert box dismissible. Set it to `false` to create a sticky alert box. diff --git a/docs/en/UI/Blazor/Page-Header.md b/docs/en/UI/Blazor/Page-Header.md new file mode 100644 index 0000000000..2c7921bbd2 --- /dev/null +++ b/docs/en/UI/Blazor/Page-Header.md @@ -0,0 +1,3 @@ +# Blazor UI: Page Header + +TODO \ No newline at end of file diff --git a/docs/en/UI/Blazor/Routing.md b/docs/en/UI/Blazor/Routing.md new file mode 100644 index 0000000000..31a5637b51 --- /dev/null +++ b/docs/en/UI/Blazor/Routing.md @@ -0,0 +1,24 @@ +# Blazor UI: Routing + +Blazor has its own [routing system](https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing) and you can use it in your applications. ABP doesn't add any new feature to it, except one small improvement for the [modular development](../../Module-Development-Basics.md). + +## AbpRouterOptions + +Blazor `Router` component requires to define `AdditionalAssemblies` when you have components in assemblies/projects other than the main application's entrance assembly. So, if you want to create razor class libraries as ABP modules, you typically want to add the module's assembly to the `AdditionalAssemblies`. In this case, you need to add your module's assembly to the `AbpRouterOptions`. + +**Example** + +````csharp +Configure(options => +{ + options.AdditionalAssemblies.Add(typeof(MyBlazorModule).Assembly); +}); +```` + +Write this code in the `ConfigureServices` method of your [module](../../Module-Development-Basics.md). + +`AbpRouterOptions` has another property, `AppAssembly`, which should be the entrance assembly of the application and typically set in the final application's module. If you've created your solution with the [application startup template](../../Startup-Templates/Application.md), it is already configured for you. + +## See Also + +* [Blazor Routing](https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing) (Microsoft Documentation) \ No newline at end of file diff --git a/docs/en/UI/Blazor/Settings.md b/docs/en/UI/Blazor/Settings.md index ad03dce5e2..e146b7ea69 100644 --- a/docs/en/UI/Blazor/Settings.md +++ b/docs/en/UI/Blazor/Settings.md @@ -1,3 +1,63 @@ -# Blazor: Settings +# Blazor UI: Settings -Blazor applications can reuse the same `ISettingProvider` service that is explained in the [settings document](../../Settings.md). \ No newline at end of file +Blazor applications can reuse the same `ISettingProvider` service that is explained in the [settings document](../../Settings.md). + +## ISettingProvider + +`ISettingProvider` is used to get the value of a setting or get the values of all the settings. + +**Example usages in a simple service** + +````csharp +public class MyService : ITransientDependency +{ + private readonly ISettingProvider _settingProvider; + + //Inject ISettingProvider in the constructor + public MyService(ISettingProvider settingProvider) + { + _settingProvider = settingProvider; + } + + public async Task FooAsync() + { + //Get a value as string. + string setting1 = await _settingProvider.GetOrNullAsync("MySettingName"); + + //Get a bool value and fallback to the default value (false) if not set. + bool setting2 = await _settingProvider.GetAsync("MyBoolSettingName"); + + //Get a bool value and fallback to the provided default value (true) if not set. + bool setting3 = await _settingProvider.GetAsync( + "MyBoolSettingName", defaultValue: true); + + //Get a bool value with the IsTrueAsync shortcut extension method + bool setting4 = await _settingProvider.IsTrueAsync("MyBoolSettingName"); + + //Get an int value or the default value (0) if not set + int setting5 = (await _settingProvider.GetAsync("MyIntegerSettingName")); + + //Get an int value or null if not provided + int? setting6 = (await _settingProvider + .GetOrNullAsync("MyIntegerSettingName"))?.To(); + } +} +```` + +**Example usage in a Razor Component** + +````csharp +@page "/" +@using Volo.Abp.Settings +@inject ISettingProvider SettingProvider +@code { + protected override async Task OnInitializedAsync() + { + bool settingValue = await SettingProvider.GetAsync("MyBoolSettingName"); + } +} +```` + +## See Also + +* [Settings](../../Settings.md) \ No newline at end of file diff --git a/docs/en/UI/Blazor/Testing.md b/docs/en/UI/Blazor/Testing.md index 32148f316a..08562c5861 100644 --- a/docs/en/UI/Blazor/Testing.md +++ b/docs/en/UI/Blazor/Testing.md @@ -1,3 +1,3 @@ # Blazor: Testing -TODO \ No newline at end of file +Coming soon. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Theming.md b/docs/en/UI/Blazor/Theming.md new file mode 100644 index 0000000000..cbc6341dab --- /dev/null +++ b/docs/en/UI/Blazor/Theming.md @@ -0,0 +1,207 @@ +# Blazor UI: Theming + +## Introduction + +ABP Framework provides a complete **UI Theming** system with the following goals: + +* Reusable [application modules](../../Modules/Index.md) are developed **theme-independent**, so they can work with any UI theme. +* UI theme is **decided by the final application**. +* The theme is distributed via a NuGet package, so it is **easily upgradable**. +* The final application can **customize** the selected theme. + +In order to accomplish these goals, ABP Framework; + +* Determines a set of **base libraries** used and adapted by all the themes. So, module and application developers can depend on and use these libraries without depending on a particular theme. +* Provides a system that consists of layout parts (like [navigation menus](Navigation-Menu.md) and [toolbars](Toolbars.md)) that is implemented by all the themes. So, the modules and the application to contribute to the layout to compose a consistent application UI. + +### Current Themes + +Currently, two themes are **officially provided**: + +* The [Basic Theme](Basic-Theme.md) is the minimalist theme with the plain Bootstrap style. It is **open source and free**. +* The [Lepton Theme](https://commercial.abp.io/themes) is a **commercial** theme developed by the core ABP team and is a part of the [ABP Commercial](https://commercial.abp.io/) license. + +## Overall + +### The Base Libraries + +All the themes must depend on the [Volo.Abp.AspNetCore.Components.WebAssembly.Theming](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Components.WebAssembly.Theming) NuGet package, so they are indirectly depending on the following libraries: + +* [Twitter Bootstrap](https://getbootstrap.com/) as the fundamental HTML/CSS framework. +* [Blazorise](https://github.com/stsrki/Blazorise) as a component library that supports the Bootstrap and adds extra components like Data Grid and Tree. +* [FontAwesome](https://fontawesome.com/) as the fundamental CSS font library. +* [Flag Icon](https://github.com/lipis/flag-icon-css) as a library to show flags of countries. + +These libraries are selected as the base libraries and available to the applications and modules. + +> Bootstrap's JavaScript part is not used since the Blazorise library already provides the necessary functionalities to the Bootstrap components in a native way. + +### The Layout + +All themes must define a layout for the application. The following image shows the user management page in the [Basic Theme](Basic-Theme.md) application layout: + +![basic-theme-application-layout-blazor](../../images/basic-theme-application-layout-blazor.png) + +And the same page is shown below with the [Lepton Theme](https://commercial.abp.io/themes) application layout: + +![lepton-theme-application-layout](../../images/lepton-theme-blazor-layout.png) + +As you can see, the page is the same, but the look is completely different in the themes above. + +The application layout typically includes the following parts; + +* A [main menu](Navigation-Menu.md) +* Main [Toolbar](Toolbars.md) with the following components; + * User menu + * Language switch dropdown +* [Page alerts](Page-Alerts.md) +* The page content (aka `@Body`) + +## Implementing a Theme + +A theme is simply a Razor Class Library. + +### The Easy Way + +The easiest way to create a new theme is to copy the [Basic Theme Source Code](https://github.com/abpframework/abp/tree/dev/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme) and customize it. Once you get a copy of the theme in your solution, remove the `Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic` NuGet package and reference to the local project. + +### Global Styles / Scripts + +A theme generally needs to add a global style to the page. ABP provides a system to manage the [Global Styles and Scripts](Global-Scripts-Styles.md). A theme can implement the `IBundleContributor` to add global style or script files to the page. + +**Example: Adding a style to the page** + +````csharp +using Volo.Abp.Bundling; + +namespace MyTheme +{ + public class MyThemeBundleContributor : IBundleContributor + { + public void AddScripts(BundleContext context) + { + + } + + public void AddStyles(BundleContext context) + { + context.Add("_content/MyTheme/styles.css"); + } + } +} +```` + +`styles.css` file should be added into the `wwwroot` folder of the theme project for this example. When you use the `abp bundle` command, this class is automatically discovered and executed to add the style to the page. + +See the [Global Styles and Scripts](Global-Scripts-Styles.md) document for more. + +### Layout Parts + +A typical Layout consists of several parts. The theme should include the necessary parts in each layout. + +**Example: The Basic Theme has the following parts for the Application Layout** + +![basic-theme-application-layout-parts](../../images/basic-theme-application-layout-parts.png) + +The application code and the modules can only show contents in the Page Content part. If they need to change the other parts (to add a menu item, to add a toolbar item, to change the application name in the branding area...) they should use the ABP Framework APIs. + +The following sections explain the fundamental parts pre-defined by the ABP Framework and can be implemented by the themes. + +> It is a good practice to split the layout into components/partials, so the final application can override them partially for customization purpose. + +#### Branding + +`IBrandingProvider` service should be used to get the name and the logo URL of the application to render in the Branding part. + +The [Application Startup Template](../../Startup-Templates/Application.md) has an implementation of this interface to set the values by the application developer. + +#### Main Menu + +`IMenuManager` service is used to get the main menu items and render on the layout. + +**Example: Get the Main Menu to render in a razor component** + +```csharp +// Code behind file of a razor component +public partial class NavMenu +{ + private readonly IMenuManager _menuManager; + + public NavMenu(IMenuManager menuManager) + { + _menuManager = menuManager; + } + + protected override async Task OnInitializedAsync() + { + var menu = await _menuManager.GetAsync(StandardMenus.Main); + //... + } +} +``` + +See the [Navigation / Menus](Navigation-Menu.md) document to learn more about the navigation system. + +#### Main Toolbar + +`IToolbarManager` service is used to get the Main Toolbar items and render on the layout. Each item of this toolbar is a Razor Component, so it may include any type of UI elements. Inject the `IToolbarManager` and use the `GetAsync` to get the toolbar items: + +````csharp +var toolbar = await _toolbarManager.GetAsync(StandardToolbars.Main); +```` + +> See the [Toolbars](Toolbars.md) document to learn more on the toolbar system. + +The theme has a responsibility to add two pre-defined items to the main toolbar: Language Selection and User Menu. To do that, create a class implementing the `IToolbarContributor` interface and add it to the `AbpToolbarOptions` as shown below: + +```csharp +Configure(options => +{ + options.Contributors.Add(new BasicThemeMainTopToolbarContributor()); +}); +``` + +##### Language Selection + +Language Selection toolbar item is generally a dropdown that is used to switch between languages. `ILanguageProvider` is used to get the list of available languages and `CultureInfo.CurrentUICulture` is used to learn the current language. + +Local Storage is used to get and set the current language with the `Abp.SelectedLanguage` key. + +**Example: Get the currently selected language** + +````csharp +var selectedLanguageName = await JsRuntime.InvokeAsync( + "localStorage.getItem", + "Abp.SelectedLanguage" + ); +```` + +**Example: Set the selected language** + +````csharp +await JsRuntime.InvokeVoidAsync( + "localStorage.setItem", + "Abp.SelectedLanguage", + "en-US" + ); +```` + +The theme should reload the page after changing the language: + +````csharp +await JsRuntime.InvokeVoidAsync("location.reload"); +```` + +##### User Menu + +User menu includes links related to the user account. `IMenuManager` is used just like the Main Menu, but this time with `StandardMenus.User` parameter like shown below: + +````csharp +var menu = await _menuManager.GetAsync(StandardMenus.User); +```` + +[ICurrentUser](../../CurrentUser.md) and [ICurrentTenant](../../Multi-Tenancy.md) services can be used to obtain the current user and tenant names. + +#### Page Alerts + +`IAlertManager` service is used to get the current page alerts to render on the layout. See the [Page Alerts](Page-Alerts.md) document to learn more. \ No newline at end of file diff --git a/docs/en/UI/Blazor/Toolbars.md b/docs/en/UI/Blazor/Toolbars.md new file mode 100644 index 0000000000..b8cca6077a --- /dev/null +++ b/docs/en/UI/Blazor/Toolbars.md @@ -0,0 +1,75 @@ +# Blazor UI: Toolbars + +The Toolbar system is used to define **toolbars** on the user interface. Modules (or your application) can add **items** to a toolbar, then the [theme](Theming.md) renders the toolbar on the **layout**. + +There is only one **standard toolbar** named "Main" (defined as a constant: `StandardToolbars.Main`). The [Basic Theme](Basic-Theme) renders the main toolbar as shown below: + +![bookstore-toolbar-highlighted](../../images/bookstore-toolbar-highlighted.png) + +In the screenshot above, there are two items added to the main toolbar: Language switch component & user menu. You can add your own items here. + +## Example: Add a Notification Icon + +In this example, we will add a **notification (bell) icon** to the left of the language switch item. A item in the toolbar should be a **Razor Component**. So, first, create a new razor component in your project (the location of the component doesn't matter): + +![bookstore-notification-view-component](../../images/blazor-notification-bell-component.png) + +The content of the `Notification.razor` is shown below: + +````html +@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase +
+ +
+@code { + private async Task ShowNotifications() + { + await Message.Info("TODO: Show notifications"); + } +} +```` + +This sample simply shows a message. In real life, you probably want to call an HTTP API to get notifications and show on the UI. + +Now, we can create a class implementing the `IToolbarContributor` interface: + +````csharp +using System.Threading.Tasks; +using MyCompanyName.MyProjectName.Blazor.Components; +using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Toolbars; + +namespace MyCompanyName.MyProjectName.Blazor +{ + public class MyToolbarContributor : IToolbarContributor + { + public Task ConfigureToolbarAsync(IToolbarConfigurationContext context) + { + if (context.Toolbar.Name == StandardToolbars.Main) + { + context.Toolbar.Items.Insert(0, new ToolbarItem(typeof(Notification))); + } + + return Task.CompletedTask; + } + } +} +```` + +This class adds the `NotificationViewComponent` as the first item in the `Main` toolbar. + +Finally, you need to add this contributor to the `AbpToolbarOptions`, in the `ConfigureServices` of your [module](../../Module-Development-Basics.md): + +````csharp +Configure(options => +{ + options.Contributors.Add(new MyToolbarContributor()); +}); +```` + +That's all, you will see the notification icon on the toolbar when you run the application: + +![bookstore-notification-icon-on-toolbar](../../images/bookstore-notification-icon-on-toolbar.png) + +## IToolbarManager + +`IToolbarManager` is used to render the toolbar. It returns the toolbar items by a toolbar name. This is generally used by the [themes](Theming.md) to render the toolbar on the layout. \ No newline at end of file diff --git a/docs/en/Upgrading.md b/docs/en/Upgrading.md index 1140c5d573..fcda081188 100644 --- a/docs/en/Upgrading.md +++ b/docs/en/Upgrading.md @@ -16,11 +16,26 @@ Run this command in the terminal while you are in the root folder of your soluti > If your solution has the Angular UI, you probably have `aspnet-core` and `angular` folders in the solution. Run this command in the parent folder of these two folders. -## The Blog Posts +### Database Migrations + +> Warning: Be careful if you are migrating your database since you may have data loss in some cases. Carefully check the generated migration code before executing it. It is suggested to take a backup of your current database. + +When you upgrade to a new version, it is good to check if there is a database schema change and upgrade your database schema if your database provider is **Entity Framework Core**; + +* Use `Add-Migration "Upgraded_To_Abp_4_1"` or a similar command in the Package Manager Console (PMC) to create a new migration (Set the `EntityFrameworkCore.DbMigrations` as the Default project in the PMC and `.DbMigrator` as the Startup Project in the Solution Explorer, in the Visual Studio). +* Run the `.DbMigrator` application to upgrade the database and seed the initial data. + +If `Add-Migration` generates an empty migration, you can use `Remove-Migration` to delete it before executing the `.DbMigrator`. + +## The Blog Posts & Guides Sometimes we introduce new features/changes that requires to make changes in the startup template. We already implement the changes in the startup template for new applications. However, in some cases you need to manually make some minor changes in your solution. -Whenever you upgrade your solution, it is strongly suggested to check the [ABP BLOG](https://blog.abp.io/?_ga=2.177248992.411298747.1597771169-1910388957.1594128976) to learn the new features and changes coming with the new version. We regularly publish posts and write these kind of changes. If the changes are not trivial, we also provide migration guides. +Whenever you upgrade your solution, it is strongly suggested to check the [ABP BLOG](https://blog.abp.io/) to learn the new features and changes coming with the new version. We regularly publish posts and write these kind of changes. + +### Migration Guides + +We prepare migration guides if the new version brings breaking changes for existing applications. See the [Migration Guides](Migration-Guides/Index.md) page for all the guides. ## Semantic Versioning & Breaking Changes diff --git a/docs/en/_resources/Diagrams.docx b/docs/en/_resources/Diagrams.docx index 424e281470..15cb38bab2 100644 Binary files a/docs/en/_resources/Diagrams.docx and b/docs/en/_resources/Diagrams.docx differ diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 4db6ae5b16..be24432203 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -11,12 +11,41 @@ "text": "Console Application", "path": "Startup-Templates/Console.md" }, + { + "text": "WPF Application", + "path": "Startup-Templates/WPF.md" + }, { "text": "Empty Web Project", "path": "Getting-Started-AspNetCore-Application.md" } ] }, + { + "text": "Startup Templates", + "items": [ + { + "text": "Overall", + "path": "Startup-Templates/Index.md" + }, + { + "text": "Application", + "path": "Startup-Templates/Application.md" + }, + { + "text": "Module", + "path": "Startup-Templates/Module.md" + }, + { + "text": "Console", + "path": "Startup-Templates/Console.md" + }, + { + "text": "WPF", + "path": "Startup-Templates/WPF.md" + } + ] + }, { "text": "Tutorials", "items": [ @@ -64,29 +93,10 @@ "path": "Tutorials/Part-10.md" } ] - } - ] - }, - { - "text": "Guides", - "items": [ + }, { - "text": "Customizing the Application Modules", - "path": "Customizing-Application-Modules-Guide.md", - "items": [ - { - "text": "Extending Entities", - "path": "Customizing-Application-Modules-Extending-Entities.md" - }, - { - "text": "Overriding Services", - "path": "Customizing-Application-Modules-Overriding-Services.md" - }, - { - "text": "Overriding the User Interface", - "path": "Customizing-Application-Modules-Overriding-User-Interface.md" - } - ] + "text": "Community Articles", + "path": "https://community.abp.io/articles" }, { "text": "Migrating from the ASP.NET Boilerplate", @@ -94,34 +104,9 @@ } ] }, - { - "text": "CLI", - "path": "CLI.md" - }, - { - "text": "Authentication & Security", - "items": [ - { - "text": "Social/External Logins", - "path": "Authentication/Social-External-Logins.md" - }, - { - "text": "CSRF/XSRF & Anti Forgery", - "path": "CSRF-Anti-Forgery.md" - } - ] - }, { "text": "Fundamentals", "items": [ - { - "text": "Configuration", - "path": "Configuration.md" - }, - { - "text": "Options", - "path": "Options.md" - }, { "text": "Dependency Injection", "path": "Dependency-Injection.md", @@ -133,16 +118,16 @@ ] }, { - "text": "Virtual File System", - "path": "Virtual-File-System.md" + "text": "Configuration", + "path": "Configuration.md" }, { - "text": "Localization", - "path": "Localization.md" + "text": "Options", + "path": "Options.md" }, { - "text": "Exception Handling", - "path": "Exception-Handling.md" + "text": "Authorization", + "path": "Authorization.md" }, { "text": "Validation", @@ -155,8 +140,8 @@ ] }, { - "text": "Authorization", - "path": "Authorization.md" + "text": "Localization", + "path": "Localization.md" }, { "text": "Caching", @@ -169,83 +154,59 @@ ] }, { - "text": "Logging", - "path": "Logging.md" - }, - { - "text": "Audit Logging", - "path": "Audit-Logging.md" + "text": "Exception Handling", + "path": "Exception-Handling.md" }, { "text": "Settings", "path": "Settings.md" }, { - "text": "Features", - "path": "Features.md" - }, - { - "text": "Data Filtering", - "path": "Data-Filtering.md" + "text": "Connection Strings", + "path": "Connection-Strings.md" }, { "text": "Object Extensions", "path": "Object-Extensions.md" + }, + { + "text": "Logging", + "path": "Logging.md" } ] }, { - "text": "Event Bus", + "text": "Infrastructure", "items": [ { - "text": "Overall", - "path": "Event-Bus.md" - }, - { - "text": "Local Event Bus", - "path": "Local-Event-Bus.md" + "text": "Audit Logging", + "path": "Audit-Logging.md" }, { - "text": "Distributed Event Bus", - "path": "Distributed-Event-Bus.md", + "text": "Background Jobs", + "path": "Background-Jobs.md", "items": [ { - "text": "RabbitMQ Integration", - "path": "Distributed-Event-Bus-RabbitMQ-Integration.md" + "text": "Hangfire Integration", + "path": "Background-Jobs-Hangfire.md" }, { - "text": "Kafka Integration", - "path": "Distributed-Event-Bus-Kafka-Integration.md" + "text": "RabbitMQ Integration", + "path": "Background-Jobs-RabbitMq.md" }, { - "text": "Rebus Integration", - "path": "Distributed-Event-Bus-Rebus-Integration.md" + "text": "Quartz Integration", + "path": "Background-Jobs-Quartz.md" } ] - } - ] - }, - { - "text": "Services", - "items": [ - { - "text": "Current User", - "path": "CurrentUser.md" - }, - { - "text": "Object to object mapping", - "path": "Object-To-Object-Mapping.md" }, { - "text": "Email Sending", + "text": "Background Workers", + "path": "Background-Workers.md", "items": [ { - "text": "Email Sending System", - "path": "Emailing.md" - }, - { - "text": "MailKit Integration", - "path": "MailKit.md" + "text": "Quartz Integration", + "path": "Background-Workers-Quartz.md" } ] }, @@ -292,87 +253,191 @@ ] }, { - "text": "Text Templating", - "path": "Text-Templating.md" + "text": "CSRF/XSRF & Anti Forgery", + "path": "CSRF-Anti-Forgery.md" + }, + { + "text": "Current User", + "path": "CurrentUser.md" + }, + { + "text": "Data Filtering", + "path": "Data-Filtering.md" + }, + { + "text": "Data Seeding", + "path": "Data-Seeding.md" + }, + { + "text": "Email Sending", + "items": [ + { + "text": "Email Sending System", + "path": "Emailing.md" + }, + { + "text": "MailKit Integration", + "path": "MailKit.md" + } + ] + }, + { + "text": "Event Bus", + "items": [ + { + "text": "Overall", + "path": "Event-Bus.md" + }, + { + "text": "Local Event Bus", + "path": "Local-Event-Bus.md" + }, + { + "text": "Distributed Event Bus", + "path": "Distributed-Event-Bus.md", + "items": [ + { + "text": "RabbitMQ Integration", + "path": "Distributed-Event-Bus-RabbitMQ-Integration.md" + }, + { + "text": "Kafka Integration", + "path": "Distributed-Event-Bus-Kafka-Integration.md" + }, + { + "text": "Rebus Integration", + "path": "Distributed-Event-Bus-Rebus-Integration.md" + } + ] + } + ] + }, + { + "text": "Features", + "path": "Features.md" }, { "text": "GUID Generation", "path": "Guid-Generation.md" }, { - "text": "Timing", - "path": "Timing.md" - } - ] - }, - { - "text": "Multi Tenancy", - "path": "Multi-Tenancy.md" - }, - { - "text": "Module Development", - "items": [ + "text": "Object to Object Mapping", + "path": "Object-To-Object-Mapping.md" + }, { - "text": "Basics", - "path": "Module-Development-Basics.md" + "text": "Text Templating", + "path": "Text-Templating.md" }, { - "text": "Plug-In Modules" + "text": "Timing", + "path": "Timing.md" }, { - "text": "Best Practices", - "path": "Best-Practices/Index.md" + "text": "Virtual File System", + "path": "Virtual-File-System.md" } ] }, { - "text": "Domain Driven Design", + "text": "Architecture", "items": [ { - "text": "Overall", - "path": "Domain-Driven-Design.md" - }, - { - "text": "Domain Layer", + "text": "Modularity", "items": [ { - "text": "Entities & Aggregate Roots", - "path": "Entities.md" + "text": "Basics", + "path": "Module-Development-Basics.md" }, { - "text": "Value Objects", - "path": "Value-Objects.md" + "text": "Plug-In Modules", + "path": "PlugIn-Modules.md" }, { - "text": "Repositories", - "path": "Repositories.md" - }, - { - "text": "Domain Services", - "path": "Domain-Services.md" + "text": "Customizing the Application Modules", + "path": "Customizing-Application-Modules-Guide.md", + "items": [ + { + "text": "Extending Entities", + "path": "Customizing-Application-Modules-Extending-Entities.md" + }, + { + "text": "Overriding Services", + "path": "Customizing-Application-Modules-Overriding-Services.md" + }, + { + "text": "Overriding the User Interface", + "path": "Customizing-Application-Modules-Overriding-User-Interface.md" + } + ] }, { - "text": "Specifications", - "path": "Specifications.md" + "text": "Best Practices", + "path": "Best-Practices/Index.md" } ] }, { - "text": "Application Layer", + "text": "Domain Driven Design", "items": [ { - "text": "Application Services", - "path": "Application-Services.md" + "text": "Overall", + "path": "Domain-Driven-Design.md" + }, + { + "text": "Domain Layer", + "items": [ + { + "text": "Entities & Aggregate Roots", + "path": "Entities.md" + }, + { + "text": "Value Objects", + "path": "Value-Objects.md" + }, + { + "text": "Repositories", + "path": "Repositories.md" + }, + { + "text": "Domain Services", + "path": "Domain-Services.md" + }, + { + "text": "Specifications", + "path": "Specifications.md" + } + ] }, { - "text": "Data Transfer Objects", - "path": "Data-Transfer-Objects.md" + "text": "Application Layer", + "items": [ + { + "text": "Application Services", + "path": "Application-Services.md" + }, + { + "text": "Data Transfer Objects", + "path": "Data-Transfer-Objects.md" + }, + { + "text": "Unit Of Work", + "path": "Unit-Of-Work.md" + } + ] }, { - "text": "Unit Of Work", - "path": "Unit-Of-Work.md" + "text": "Guide: Implementing DDD", + "path": "Domain-Driven-Design-Implementation-Guide.md" } ] + }, + { + "text": "Multi Tenancy", + "path": "Multi-Tenancy.md" + }, + { + "text": "Microservices", + "path": "Microservice-Architecture.md" } ] }, @@ -562,16 +627,62 @@ "text": "Overall", "path": "UI/Blazor/Overall.md" }, + { + "text": "Navigation / Menu", + "path": "UI/Blazor/Navigation-Menu.md" + }, + { + "text": "Localization", + "path": "UI/Blazor/Localization.md" + }, + { + "text": "Theming", + "items": [ + { + "text": "Overall", + "path": "UI/Blazor/Theming.md" + }, + { + "text": "The Basic Theme", + "path": "UI/Blazor/Basic-Theme.md" + }, + { + "text": "Branding", + "path": "UI/Blazor/Branding.md" + }, + { + "text": "Page Header", + "path": "UI/Blazor/Page-Header.md" + }, + { + "text": "Toolbars", + "path": "UI/Blazor/Toolbars.md" + } + ] + }, + { + "text": "Security", + "items": [ + { + "text": "Authentication", + "path": "UI/Blazor/Authentication.md" + }, + { + "text": "Authorization", + "path": "UI/Blazor/Authorization.md" + } + ] + }, { "text": "Services", "items": [ { - "text": "Localization", - "path": "UI/Blazor/Localization.md" + "text": "Current User", + "path": "UI/Blazor/CurrentUser.md" }, { - "text": "Settings", - "path": "UI/Blazor/Settings.md" + "text": "Current Tenant", + "path": "UI/Blazor/CurrentTenant.md" }, { "text": "Notification", @@ -580,18 +691,38 @@ { "text": "Message", "path": "UI/Blazor/Message.md" + }, + { + "text": "Page Alerts", + "path": "UI/Blazor/Page-Alerts.md" } ] + }, + { + "text": "Settings", + "path": "UI/Blazor/Settings.md" + }, + { + "text": "Error Handling", + "path": "UI/Blazor/Error-Handling.md" + }, + { + "text": "Customization / Overriding Components", + "path": "UI/Blazor/Customization-Overriding-Components.md" + }, + { + "text": "Global Scripts & Styles", + "path": "UI/Blazor/Global-Scripts-Styles.md" + }, + { + "text": "Routing", + "path": "UI/Blazor/Routing.md" } ] }, { "text": "Angular", "items": [ - { - "text": "Migration Guide v2.x to v3", - "path": "UI/Angular/Migration-Guide-v3.md" - }, { "text": "Quick Start", "path": "UI/Angular/Quick-Start.md" @@ -621,8 +752,8 @@ "text": "Core Functionality", "items": [ { - "text": "Config State", - "path": "UI/Angular/Config-State.md" + "text": "Config State Service", + "path": "UI/Angular/Config-State-Service.md" }, { "text": "HTTP Requests", @@ -743,57 +874,44 @@ "path": "Data-Access.md" }, { - "text": "Connection Strings", - "path": "Connection-Strings.md" - }, - { - "text": "Database Providers", + "text": "Entity Framework Core", + "path": "Entity-Framework-Core.md", "items": [ { - "text": "Entity Framework Core", - "path": "Entity-Framework-Core.md", + "text": "Database Migrations", + "path": "Entity-Framework-Core-Migrations.md" + }, + { + "text": "Switch DBMS", + "path": "Entity-Framework-Core-Other-DBMS.md", "items": [ { - "text": "Database Migrations", - "path": "Entity-Framework-Core-Migrations.md" - }, - { - "text": "Switch DBMS", - "path": "Entity-Framework-Core-Other-DBMS.md", - "items": [ - { - "text": "To MySQL", - "path": "Entity-Framework-Core-MySQL.md" - }, - { - "text": "To PostgreSQL", - "path": "Entity-Framework-Core-PostgreSQL.md" - }, - { - "text": "To Oracle", - "path": "Entity-Framework-Core-Oracle.md" - }, - { - "text": "To SQLite", - "path": "Entity-Framework-Core-SQLite.md" - } - ] + "text": "To MySQL", + "path": "Entity-Framework-Core-MySQL.md" + }, + { + "text": "To PostgreSQL", + "path": "Entity-Framework-Core-PostgreSQL.md" + }, + { + "text": "To Oracle", + "path": "Entity-Framework-Core-Oracle.md" + }, + { + "text": "To SQLite", + "path": "Entity-Framework-Core-SQLite.md" } ] - }, - { - "text": "MongoDB", - "path": "MongoDB.md" - }, - { - "text": "Dapper", - "path": "Dapper.md" } ] }, { - "text": "Data Seeding", - "path": "Data-Seeding.md" + "text": "MongoDB", + "path": "MongoDB.md" + }, + { + "text": "Dapper", + "path": "Dapper.md" } ] }, @@ -807,111 +925,136 @@ ] }, { - "text": "Background", + "text": "Testing", + "path": "Testing.md" + }, + { + "text": "Samples", "items": [ { - "text": "Background Jobs", - "path": "Background-Jobs.md", - "items": [ - { - "text": "Hangfire Integration", - "path": "Background-Jobs-Hangfire.md" - }, - { - "text": "RabbitMQ Integration", - "path": "Background-Jobs-RabbitMq.md" - }, - { - "text": "Quartz Integration", - "path": "Background-Jobs-Quartz.md" - } - ] + "text": "All Samples", + "path": "Samples/Index.md" }, { - "text": "Background Workers", - "path": "Background-Workers.md", - "items": [ - { - "text": "Quartz Integration", - "path": "Background-Workers-Quartz.md" - } - ] + "text": "Microservice Demo", + "path": "Samples/Microservice-Demo.md" } ] }, { - "text": "Testing", - "path": "Testing.md" - }, - { - "text": "Startup Templates", + "text": "Application Modules", "items": [ { "text": "Overall", - "path": "Startup-Templates/Index.md" + "path": "Modules/Index.md" }, { - "text": "Application", - "path": "Startup-Templates/Application.md" + "text": "Account", + "path": "Modules/Account.md" }, { - "text": "Module", - "path": "Startup-Templates/Module.md" + "text": "Audit Logging", + "path": "Modules/Audit-Logging.md" }, { - "text": "Console", - "path": "Startup-Templates/Console.md" + "text": "Background Jobs", + "path": "Modules/Background-Jobs.md" + }, + { + "text": "Blogging", + "path": "Modules/Blogging.md" + }, + { + "text": "Client Simulation", + "path": "Modules/Client-Simulation.md" + }, + { + "text": "CMS Kit", + "path": "Modules/Cms-Kit.md" + }, + { + "text": "Docs", + "path": "Modules/Docs.md" + }, + { + "text": "Feature Management", + "path": "Modules/Feature-Management.md" + }, + { + "text": "Identity", + "path": "Modules/Identity.md" + }, + { + "text": "IdentityServer", + "path": "Modules/IdentityServer.md" + }, + { + "text": "Permission Management", + "path": "Modules/Permission-Management.md" + }, + { + "text": "Setting Management", + "path": "Modules/Setting-Management.md" + }, + { + "text": "Tenant Management", + "path": "Modules/Tenant-Management.md" + }, + { + "text": "Users", + "path": "Modules/Users.md" + }, + { + "text": "Virtual File Explorer", + "path": "Modules/Virtual-File-Explorer.md" } ] }, { - "text": "Samples", + "text": "Release Information", "items": [ { - "text": "All Samples", - "path": "Samples/Index.md" + "text": "Upgrading", + "path": "Upgrading.md" }, { - "text": "Microservice Demo", - "path": "Samples/Microservice-Demo.md" + "text": "Official Packages", + "path": "https://abp.io/packages" + }, + { + "text": "Preview Releases", + "path": "Previews.md" + }, + { + "text": "Nightly Builds", + "path": "Nightly-Builds.md" + }, + { + "text": "Road Map", + "path": "Road-Map.md" + }, + { + "text": "Migration Guides", + "path": "Migration-Guides/Index.md" } ] }, { - "text": "Application Modules", - "path": "Modules/Index.md" - }, - { - "text": "Microservice Architecture", - "path": "Microservice-Architecture.md" - }, - { - "text": "Preview Releases", - "path": "Previews.md" - }, - { - "text": "Nightly Builds", - "path": "Nightly-Builds.md" - }, - { - "text": "Road Map", - "path": "Road-Map.md" - }, - { - "text": "Upgrading", - "path": "Upgrading.md" + "text": "Reference", + "items": [ + { + "text": "CLI", + "path": "CLI.md" + }, + { + "text": "API Documentation", + "path": "{ApiDocumentationUrl}" + } + ] }, { "text": "Contribution Guide", "path": "Contribution/Index.md" - }, - { - "text": "API Documentation", - "path": "{ApiDocumentationUrl}" - }, - { - "text": "Official Packages", - "path": "https://abp.io/packages" } ] } diff --git a/docs/en/images/add-new-propert-to-user-database-extra-properties.png b/docs/en/images/add-new-propert-to-user-database-extra-properties.png new file mode 100644 index 0000000000..90c697461e Binary files /dev/null and b/docs/en/images/add-new-propert-to-user-database-extra-properties.png differ diff --git a/docs/en/images/add-new-propert-to-user-database-field.png b/docs/en/images/add-new-propert-to-user-database-field.png new file mode 100644 index 0000000000..334ba0aa35 Binary files /dev/null and b/docs/en/images/add-new-propert-to-user-database-field.png differ diff --git a/docs/en/images/add-new-property-enum.png b/docs/en/images/add-new-property-enum.png new file mode 100644 index 0000000000..34a14b1bfb Binary files /dev/null and b/docs/en/images/add-new-property-enum.png differ diff --git a/docs/en/images/add-new-property-to-user-form-validation-error-custom.png b/docs/en/images/add-new-property-to-user-form-validation-error-custom.png new file mode 100644 index 0000000000..6bb1799e19 Binary files /dev/null and b/docs/en/images/add-new-property-to-user-form-validation-error-custom.png differ diff --git a/docs/en/images/add-new-property-to-user-form-validation-error.png b/docs/en/images/add-new-property-to-user-form-validation-error.png new file mode 100644 index 0000000000..dd2eb8ad1d Binary files /dev/null and b/docs/en/images/add-new-property-to-user-form-validation-error.png differ diff --git a/docs/en/images/add-new-property-to-user-form.png b/docs/en/images/add-new-property-to-user-form.png new file mode 100644 index 0000000000..bc12a6d5ad Binary files /dev/null and b/docs/en/images/add-new-property-to-user-form.png differ diff --git a/docs/en/images/add-new-property-to-user-table.png b/docs/en/images/add-new-property-to-user-table.png new file mode 100644 index 0000000000..a2a15087cc Binary files /dev/null and b/docs/en/images/add-new-property-to-user-table.png differ diff --git a/docs/en/images/basic-theme-application-layout-blazor.png b/docs/en/images/basic-theme-application-layout-blazor.png new file mode 100644 index 0000000000..f01becad07 Binary files /dev/null and b/docs/en/images/basic-theme-application-layout-blazor.png differ diff --git a/docs/en/images/basic-wpf-application-solution.png b/docs/en/images/basic-wpf-application-solution.png new file mode 100644 index 0000000000..5943acd93f Binary files /dev/null and b/docs/en/images/basic-wpf-application-solution.png differ diff --git a/docs/en/images/blazor-generic-exception-message.png b/docs/en/images/blazor-generic-exception-message.png new file mode 100644 index 0000000000..5e128003cf Binary files /dev/null and b/docs/en/images/blazor-generic-exception-message.png differ diff --git a/docs/en/images/blazor-message-confirm.png b/docs/en/images/blazor-message-confirm.png new file mode 100644 index 0000000000..fe03620283 Binary files /dev/null and b/docs/en/images/blazor-message-confirm.png differ diff --git a/docs/en/images/blazor-message-error.png b/docs/en/images/blazor-message-error.png new file mode 100644 index 0000000000..5192eae1e9 Binary files /dev/null and b/docs/en/images/blazor-message-error.png differ diff --git a/docs/en/images/blazor-message-success.png b/docs/en/images/blazor-message-success.png new file mode 100644 index 0000000000..592fac8b7d Binary files /dev/null and b/docs/en/images/blazor-message-success.png differ diff --git a/docs/en/images/blazor-notification-bell-component.png b/docs/en/images/blazor-notification-bell-component.png new file mode 100644 index 0000000000..65934ec24b Binary files /dev/null and b/docs/en/images/blazor-notification-bell-component.png differ diff --git a/docs/en/images/blazor-notification-success.png b/docs/en/images/blazor-notification-success.png new file mode 100644 index 0000000000..d68dcf47d8 Binary files /dev/null and b/docs/en/images/blazor-notification-success.png differ diff --git a/docs/en/images/blazor-page-alert-example.png b/docs/en/images/blazor-page-alert-example.png new file mode 100644 index 0000000000..799826e57f Binary files /dev/null and b/docs/en/images/blazor-page-alert-example.png differ diff --git a/docs/en/images/blazor-user-friendly-exception.png b/docs/en/images/blazor-user-friendly-exception.png new file mode 100644 index 0000000000..fa2a70d931 Binary files /dev/null and b/docs/en/images/blazor-user-friendly-exception.png differ diff --git a/docs/en/images/bookstore-branding-blazor.png b/docs/en/images/bookstore-branding-blazor.png new file mode 100644 index 0000000000..74ddf35f0f Binary files /dev/null and b/docs/en/images/bookstore-branding-blazor.png differ diff --git a/docs/en/images/bookstore-logo-blazor.png b/docs/en/images/bookstore-logo-blazor.png new file mode 100644 index 0000000000..4e01569813 Binary files /dev/null and b/docs/en/images/bookstore-logo-blazor.png differ diff --git a/docs/en/images/db-options.png b/docs/en/images/db-options.png new file mode 100644 index 0000000000..d9dc2ed0f4 Binary files /dev/null and b/docs/en/images/db-options.png differ diff --git a/docs/en/images/ddd-microservice-simple.png b/docs/en/images/ddd-microservice-simple.png new file mode 100644 index 0000000000..1217b243c8 Binary files /dev/null and b/docs/en/images/ddd-microservice-simple.png differ diff --git a/docs/en/images/domain-driven-design-aggregate-keep-small.png b/docs/en/images/domain-driven-design-aggregate-keep-small.png new file mode 100644 index 0000000000..56f805ebbe Binary files /dev/null and b/docs/en/images/domain-driven-design-aggregate-keep-small.png differ diff --git a/docs/en/images/domain-driven-design-clean-architecture.png b/docs/en/images/domain-driven-design-clean-architecture.png new file mode 100644 index 0000000000..4ab6d2c93b Binary files /dev/null and b/docs/en/images/domain-driven-design-clean-architecture.png differ diff --git a/docs/en/images/domain-driven-design-domain-vs-application-logic.png b/docs/en/images/domain-driven-design-domain-vs-application-logic.png new file mode 100644 index 0000000000..e370cba71e Binary files /dev/null and b/docs/en/images/domain-driven-design-domain-vs-application-logic.png differ diff --git a/docs/en/images/domain-driven-design-entity-primary-keys.png b/docs/en/images/domain-driven-design-entity-primary-keys.png new file mode 100644 index 0000000000..7ee0096222 Binary files /dev/null and b/docs/en/images/domain-driven-design-entity-primary-keys.png differ diff --git a/docs/en/images/domain-driven-design-example-domain-schema.png b/docs/en/images/domain-driven-design-example-domain-schema.png new file mode 100644 index 0000000000..fe3075b141 Binary files /dev/null and b/docs/en/images/domain-driven-design-example-domain-schema.png differ diff --git a/docs/en/images/domain-driven-design-issue-aggregate-diagram.png b/docs/en/images/domain-driven-design-issue-aggregate-diagram.png new file mode 100644 index 0000000000..244564126a Binary files /dev/null and b/docs/en/images/domain-driven-design-issue-aggregate-diagram.png differ diff --git a/docs/en/images/domain-driven-design-layers.png b/docs/en/images/domain-driven-design-layers.png new file mode 100644 index 0000000000..f2fc9af097 Binary files /dev/null and b/docs/en/images/domain-driven-design-layers.png differ diff --git a/docs/en/images/domain-driven-design-multiple-applications.png b/docs/en/images/domain-driven-design-multiple-applications.png new file mode 100644 index 0000000000..6db4fc6443 Binary files /dev/null and b/docs/en/images/domain-driven-design-multiple-applications.png differ diff --git a/docs/en/images/domain-driven-design-project-relations.png b/docs/en/images/domain-driven-design-project-relations.png new file mode 100644 index 0000000000..b7878d1385 Binary files /dev/null and b/docs/en/images/domain-driven-design-project-relations.png differ diff --git a/docs/en/images/domain-driven-design-reference-by-id-sample.png b/docs/en/images/domain-driven-design-reference-by-id-sample.png new file mode 100644 index 0000000000..48a1913654 Binary files /dev/null and b/docs/en/images/domain-driven-design-reference-by-id-sample.png differ diff --git a/docs/en/images/domain-driven-design-vs-solution.png b/docs/en/images/domain-driven-design-vs-solution.png new file mode 100644 index 0000000000..ef0f51a418 Binary files /dev/null and b/docs/en/images/domain-driven-design-vs-solution.png differ diff --git a/docs/en/images/domain-driven-design-web-request-flow.png b/docs/en/images/domain-driven-design-web-request-flow.png new file mode 100644 index 0000000000..a9cb98e01f Binary files /dev/null and b/docs/en/images/domain-driven-design-web-request-flow.png differ diff --git a/docs/en/images/lepton-theme-blazor-layout.png b/docs/en/images/lepton-theme-blazor-layout.png new file mode 100644 index 0000000000..e4211b367e Binary files /dev/null and b/docs/en/images/lepton-theme-blazor-layout.png differ diff --git a/docs/en/images/simple-plug-in-dll-file.png b/docs/en/images/simple-plug-in-dll-file.png new file mode 100644 index 0000000000..3155708d68 Binary files /dev/null and b/docs/en/images/simple-plug-in-dll-file.png differ diff --git a/docs/en/images/simple-plugin-library.png b/docs/en/images/simple-plugin-library.png new file mode 100644 index 0000000000..9fefd57dda Binary files /dev/null and b/docs/en/images/simple-plugin-library.png differ diff --git a/docs/en/images/simple-plugin-output.png b/docs/en/images/simple-plugin-output.png new file mode 100644 index 0000000000..71f6a78c0e Binary files /dev/null and b/docs/en/images/simple-plugin-output.png differ diff --git a/docs/en/images/simple-razor-plug-in-dll-file.png b/docs/en/images/simple-razor-plug-in-dll-file.png new file mode 100644 index 0000000000..06b7a565fe Binary files /dev/null and b/docs/en/images/simple-razor-plug-in-dll-file.png differ diff --git a/docs/en/images/simple-razor-plugin.png b/docs/en/images/simple-razor-plugin.png new file mode 100644 index 0000000000..92e0e00d29 Binary files /dev/null and b/docs/en/images/simple-razor-plugin.png differ diff --git a/docs/en/images/table-column-extension-example.png b/docs/en/images/table-column-extension-example.png new file mode 100644 index 0000000000..84d87bf46c Binary files /dev/null and b/docs/en/images/table-column-extension-example.png differ diff --git a/docs/en/images/ui-options.png b/docs/en/images/ui-options.png new file mode 100644 index 0000000000..bd211a8914 Binary files /dev/null and b/docs/en/images/ui-options.png differ diff --git a/docs/en/images/user-action-extension-click-me.png b/docs/en/images/user-action-extension-click-me.png new file mode 100644 index 0000000000..4046630f48 Binary files /dev/null and b/docs/en/images/user-action-extension-click-me.png differ diff --git a/docs/en/images/user-action-extension-on-solution.png b/docs/en/images/user-action-extension-on-solution.png new file mode 100644 index 0000000000..5f58d3f302 Binary files /dev/null and b/docs/en/images/user-action-extension-on-solution.png differ diff --git a/docs/zh-Hans/Application-Services.md b/docs/zh-Hans/Application-Services.md index 6bb18daa37..e68217a94d 100644 --- a/docs/zh-Hans/Application-Services.md +++ b/docs/zh-Hans/Application-Services.md @@ -353,12 +353,12 @@ public class DistrictAppService { } - protected override async Task DeleteByIdAsync(DistrictKey id) + protected async override Task DeleteByIdAsync(DistrictKey id) { await Repository.DeleteAsync(d => d.CityId == id.CityId && d.Name == id.Name); } - protected override async Task GetEntityByIdAsync(DistrictKey id) + protected async override Task GetEntityByIdAsync(DistrictKey id) { return await AsyncQueryableExecuter.FirstOrDefaultAsync( Repository.Where(d => d.CityId == id.CityId && d.Name == id.Name) diff --git a/docs/zh-Hans/Authentication/Social-External-Logins.md b/docs/zh-Hans/Authentication/Social-External-Logins.md index 55ab97374c..a1cdbb86ce 100644 --- a/docs/zh-Hans/Authentication/Social-External-Logins.md +++ b/docs/zh-Hans/Authentication/Social-External-Logins.md @@ -1,33 +1,3 @@ # 社交/外部登录 - -[帐户模块](../Modules/Account.md)已配置为开箱即用的处理社交或外部登录. 你可以按照ASP.NET Core文档向你的应用程序添加社交/外部登录提供程序. - -## 示例: Facebook 认证 - -按照[ASP.NET Core Facebook集成文档](https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/social/facebook-logins)向你应用程序添加Facebook登录. - -#### 添加NuGet包 - -添加[Microsoft.AspNetCore.Authentication.Facebook]包到你的项目. 基于你的架构,可能是 `.Web`,`.IdentityServer`(对于分层启动)或 `.Host` 项目. - -#### 配置提供程序 - -在你模块的 `ConfigureServices` 方法中使用 `.AddFacebook(...)` 扩展方法来配置客户端: - -````csharp -context.Services.AddAuthentication() - .AddFacebook(facebook => - { - facebook.AppId = "..."; - facebook.AppSecret = "..."; - facebook.Scope.Add("email"); - facebook.Scope.Add("public_profile"); - }); -```` - -> 最佳实践是使用 `appsettings.json` 或ASP.NET Core用户机密系统来存储你的凭据,而不是像这样硬编码值. 请参阅[微软](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins)文档了解如何使用用户机密. - -## Angular UI - -从v3.1开始,Angular UI使用授权码流程(作为最佳实践)通过重定向到MVC UI登录页面来对用户进行身份验证. 因此,即使你使用的是Angular UI,社交/外部登录集成也与上面说明的相同.并且可以开箱即用. \ No newline at end of file +> 文档已经移动其他位置. 参阅[账户模块](../Modules/Account.md)文档. \ No newline at end of file diff --git a/docs/zh-Hans/Authorization.md b/docs/zh-Hans/Authorization.md index 96caae1404..db0dfdb654 100644 --- a/docs/zh-Hans/Authorization.md +++ b/docs/zh-Hans/Authorization.md @@ -343,7 +343,7 @@ public class SystemAdminPermissionValueProvider : PermissionValueProvider public override string Name => "SystemAdmin"; - public override async Task + public async override Task CheckAsync(PermissionValueCheckContext context) { if (context.Principal?.FindFirst("User_Type")?.Value == "SystemAdmin") diff --git a/docs/zh-Hans/Background-Workers.md b/docs/zh-Hans/Background-Workers.md index 1daedde384..26bafed2da 100644 --- a/docs/zh-Hans/Background-Workers.md +++ b/docs/zh-Hans/Background-Workers.md @@ -54,7 +54,7 @@ public class PassiveUserCheckerWorker : AsyncPeriodicBackgroundWorkerBase Timer.Period = 600000; //10 minutes } - protected override async Task DoWorkAsync( + protected async override Task DoWorkAsync( PeriodicBackgroundWorkerContext workerContext) { Logger.LogInformation("Starting: Setting status of inactive users..."); diff --git a/docs/zh-Hans/Blog-Posts/2020-05-08 v2_7_Release/Post.md b/docs/zh-Hans/Blog-Posts/2020-05-08 v2_7_Release/Post.md index 0f97391eb8..bc448179cc 100644 --- a/docs/zh-Hans/Blog-Posts/2020-05-08 v2_7_Release/Post.md +++ b/docs/zh-Hans/Blog-Posts/2020-05-08 v2_7_Release/Post.md @@ -121,7 +121,7 @@ ABP框架的[异常处理系统](https://docs.abp.io/en/abp/latest/Exception-Han ````csharp public class MyExceptionSubscriber : ExceptionSubscriber { - public override async Task HandleAsync(ExceptionNotificationContext context) + public async override Task HandleAsync(ExceptionNotificationContext context) { //TODO... } diff --git a/docs/zh-Hans/Customizing-Application-Modules-Overriding-Services.md b/docs/zh-Hans/Customizing-Application-Modules-Overriding-Services.md index 21245cec16..b8abe99cdc 100644 --- a/docs/zh-Hans/Customizing-Application-Modules-Overriding-Services.md +++ b/docs/zh-Hans/Customizing-Application-Modules-Overriding-Services.md @@ -59,7 +59,6 @@ context.Services.Replace( ### 示例: 重写服务方法 ````csharp -//[RemoteService(IsEnabled = false)] // 如果你在使用动态控制器,为了避免为应用服务创建重复的控制器, 你可以禁用远程访问. [Dependency(ReplaceServices = true)] [ExposeServices(typeof(IIdentityUserAppService), typeof(IdentityUserAppService), typeof(MyIdentityUserAppService))] public class MyIdentityUserAppService : IdentityUserAppService @@ -76,7 +75,7 @@ public class MyIdentityUserAppService : IdentityUserAppService { } - public override async Task CreateAsync(IdentityUserCreateDto input) + public async override Task CreateAsync(IdentityUserCreateDto input) { if (input.PhoneNumber.IsNullOrWhiteSpace()) { @@ -109,33 +108,33 @@ public class MyIdentityUserManager : IdentityUserManager { public MyIdentityUserManager( IdentityUserStore store, - IIdentityRoleRepository roleRepository, + IIdentityRoleRepository roleRepository, IIdentityUserRepository userRepository, - IOptions optionsAccessor, + IOptions optionsAccessor, IPasswordHasher passwordHasher, - IEnumerable> userValidators, - IEnumerable> passwordValidators, + IEnumerable> userValidators, + IEnumerable> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, - ILogger logger, - ICancellationTokenProvider cancellationTokenProvider) : + ILogger logger, + ICancellationTokenProvider cancellationTokenProvider) : base(store, roleRepository, - userRepository, - optionsAccessor, - passwordHasher, - userValidators, + userRepository, + optionsAccessor, + passwordHasher, + userValidators, passwordValidators, - keyNormalizer, - errors, - services, - logger, + keyNormalizer, + errors, + services, + logger, cancellationTokenProvider) { } - public override async Task CreateAsync(IdentityUser user) + public async override Task CreateAsync(IdentityUser user) { if (user.PhoneNumber.IsNullOrWhiteSpace()) { @@ -251,8 +250,8 @@ ObjectExtensionManager.Instance .AddOrUpdateProperty( new[] { - typeof(IdentityUserDto), - typeof(IdentityUserCreateDto), + typeof(IdentityUserDto), + typeof(IdentityUserCreateDto), typeof(IdentityUserUpdateDto) }, "SocialSecurityNumber" diff --git a/docs/zh-Hans/Data-Access.md b/docs/zh-Hans/Data-Access.md index 68baa6dd87..bf3eb479c8 100644 --- a/docs/zh-Hans/Data-Access.md +++ b/docs/zh-Hans/Data-Access.md @@ -8,4 +8,8 @@ ABP框架被设计为与数据库无关, 它通过[仓储](Repositories.md)和[ * [MongoDB](MongoDB.md) * [Dapper](Dapper.md) -在以后的版本中可能会添加更多的提供程序. \ No newline at end of file +## 另请参阅 + +* [连接字符串](Connection-Strings.md) +* [种子数据](Data-Seeding.md) +* [数据过滤](Data-Filtering.md) \ No newline at end of file diff --git a/docs/zh-Hans/Entity-Framework-Core-Migrations.md b/docs/zh-Hans/Entity-Framework-Core-Migrations.md index c6f1086540..266c0f46b0 100644 --- a/docs/zh-Hans/Entity-Framework-Core-Migrations.md +++ b/docs/zh-Hans/Entity-Framework-Core-Migrations.md @@ -235,7 +235,7 @@ public static class BackgroundJobsDbContextModelCreatingExtensions } ```` -此u还获取选项用于更改此模块的数据库表前缀和模式,但在这里并不重要. +此扩展方法还提供了选项用于更改此模块的数据库表前缀和模式,但在这里并不重要. 最终的应用程序在 `MigrationsDbContext` 类中调用扩展方法, 因此它可以确定此 `MigrationsDbContext` 维护的数据库中包含哪些模块. 如果要创建第二个数据库并将某些模块表移动到第二个数据库,则需要有第二个`MigrationsDbContext` 类,该类仅调用相关模块的扩展方法. 下一部分将详细介绍该主题. @@ -883,4 +883,4 @@ public class BookStoreDbMigratorModule : AbpModule ## 结论 -本文档说明了如何拆分数据库以及管理Entity Framework Core解决方案的数据库迁移. 简而言之,你需要为每个不同的数据库创建一个单独的迁移项目. \ No newline at end of file +本文档说明了如何拆分数据库以及管理Entity Framework Core解决方案的数据库迁移. 简而言之,你需要为每个不同的数据库创建一个单独的迁移项目. diff --git a/docs/zh-Hans/Entity-Framework-Core.md b/docs/zh-Hans/Entity-Framework-Core.md index 211ec4d65f..b5252b86c0 100644 --- a/docs/zh-Hans/Entity-Framework-Core.md +++ b/docs/zh-Hans/Entity-Framework-Core.md @@ -263,7 +263,7 @@ context.Services.AddAbpDbContext(options => 在你想要覆盖默认仓储方法对其自定义时,这一点非常需要. 例如你可能希望自定义`DeleteAsync`方法覆盖默认实现 ````csharp -public override async Task DeleteAsync( +public async override Task DeleteAsync( Guid id, bool autoSave = false, CancellationToken cancellationToken = default) @@ -365,7 +365,7 @@ public class MyRepositoryBase : EfCoreRepository where TEntity : class, IEntity { - public MyRepositoryBase(IDbContextProvider dbContextProvider) + public MyRepositoryBase(IDbContextProvider dbContextProvider) : base(dbContextProvider) { } @@ -447,4 +447,4 @@ context.Services.AddAbpDbContext(options => ## 另请参阅 -* [实体](Entities.md) \ No newline at end of file +* [实体](Entities.md) diff --git a/docs/zh-Hans/Getting-Started-AspNetCore-Application.md b/docs/zh-Hans/Getting-Started-AspNetCore-Application.md index 0334609bd3..be5e50c2bd 100644 --- a/docs/zh-Hans/Getting-Started-AspNetCore-Application.md +++ b/docs/zh-Hans/Getting-Started-AspNetCore-Application.md @@ -1,194 +1,160 @@ -## 在AspNet Core MVC Web Application中使用ABP - -本教程将介绍如何开始以最少的依赖关系开始使用ABP开发. - -通常情况下你需要下载一个 ***[启动模板](Getting-Started-AspNetCore-MVC-Template.md)*** - -### 创建一个新项目 - -1. 使用Visual Studio创建一个空的AspNet Core Web Application: - -![](images/create-new-aspnet-core-application.png) - -2. 选择空模板 - -![](images/select-empty-web-application.png) - -你可以选择其它模板,但是我想要从一个简洁的项目演示它. - -### 安装 Volo.Abp.AspNetCore.Mvc 包 - -Volo.Abp.AspNetCore.Mvc是ABP集成AspNet Core MVC的包,请安装它到你项目中: - -```` -Install-Package Volo.Abp.AspNetCore.Mvc -```` - -### 创建ABP模块 - -ABP是一个模块化框架,它需要一个**启动 (根) 模块**继承自``AbpModule``: - -````C# -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.Hosting; -using Volo.Abp; -using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.Modularity; - -namespace BasicAspNetCoreApplication -{ - [DependsOn(typeof(AbpAspNetCoreMvcModule))] - public class AppModule : AbpModule - { - public override void OnApplicationInitialization( - ApplicationInitializationContext context) - { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Error"); - } - - app.UseStaticFiles(); - app.UseRouting(); - app.UseConfiguredEndpoints(); - } - } -} -```` - -``AppModule`` 是应用程序启动模块的好名称(建议你的启动模块也使用这个命名). - -ABP的包定义了这个模块类,模块可以依赖其它模块.在上面的代码中 ``AppModule`` 依赖于 ``AbpAspNetCoreMvcModule`` (模块存在于Volo.Abp.AspNetCore.Mvc包中). 安装新的ABP的包后添加``DependsOn``是很常见的做法. - -我们在此模块类中配置ASP.NET Core管道,而不是Startup类中. - -### 启动类 - -接下来修改启动类集成ABP模块系统: - -````C# -using System; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; - -namespace BasicAspNetCoreApplication -{ - public class Startup - { - public IServiceProvider ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - - return services.BuildServiceProviderFromFactory(); - } - - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } - } -} - -```` - -修改``ConfigureServices``方法的返回值为``IServiceProvider``(默认是``void``).这个修改允许我们替换AspNet Core的依赖注入框架. (参阅下面的Autofac集成部分). ``services.AddApplication()``添加了所有模块中定义的全部服务. - -``app.InitializeApplication()`` 调用 ``Configure`` 方法初始化并启动应用程序 - -### Hello World! - -上面的应用程序没有什么功能,让我们创建一个MVC控制器实现一些功能: - -````C# -using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc; - -namespace BasicAspNetCoreApplication.Controllers -{ - public class HomeController : AbpController - { - public IActionResult Index() - { - return Content("Hello World!"); - } - } -} - -```` - -如果运行这个应用程序你会在页面中看到"Hello World!". - -Derived ``HomeController`` from ``AbpController`` instead of standard ``Controller`` class. This is not required, but ``AbpController`` class has useful base properties and methods to make your development easier. - -从``AbpController``派生``HomeController`` 而不是继承自``Controller``类.虽然这不是强制要求,但是``AbpController``类有很多有用的有属性和方法,使你的开发更容易. - -### 使用 Autofac 依赖注入框架 - -虽然AspNet Core的依赖注入(DI)系统适用于基本要求,但Autofac提供了属性注入和方法拦截等高级功能,这些功能是ABP执行高级应用程序框架功能所必需的. - -用Autofac取代AspNet Core的DI系统并集成到ABP非常简单. - -1. 安装 Volo.Abp.Autofac 包 - -```` -Install-Package Volo.Abp.Autofac -```` - -2. 添加 ``AbpAutofacModule`` 依赖 - -````C# -[DependsOn(typeof(AbpAspNetCoreMvcModule))] -[DependsOn(typeof(AbpAutofacModule))] // 在模块上添加依赖AbpAutofacModule -public class AppModule : AbpModule -{ - ... -} -```` - -3. 修改在``Startup``类下的``services.AddApplication();``如下所示: - -````C# -services.AddApplication(options => -{ - options.UseAutofac(); // 集成 Autofac -}); -```` - -4. 更新 `Program.cs`代码, 不再使用`WebHost.CreateDefaultBuilder()`方法(因为它使用默认的DI容器): - - ````csharp -public class Program -{ - public static void Main(string[] args) - { - /* - https://github.com/aspnet/AspNetCore/issues/4206#issuecomment-445612167 - CurrentDirectoryHelpers 文件位于: \framework\src\Volo.Abp.AspNetCore.Mvc\Microsoft\AspNetCore\InProcess\CurrentDirectoryHelpers.cs - 当升级到ASP.NET Core 3.0的时候将会删除这个类. - */ - CurrentDirectoryHelpers.SetCurrentDirectory(); - - BuildWebHostInternal(args).Run(); - } - public static IWebHost BuildWebHostInternal(string[] args) => - new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIIS() - .UseIISIntegration() - .UseStartup() - .Build(); -} -```` - - -### 源码 - -从[此处](https://github.com/abpframework/abp-samples/tree/master/BasicAspNetCoreApplication)获取本教程中创建的示例项目的源代码. +# 在AspNet Core MVC Web Application中使用ABP + +本教程将介绍如何开始以最少的依赖关系开始使用ABP开发. + +通常情况下你需要下载一个 **[启动模板](Getting-Started-AspNetCore-MVC-Template.md)** + +## 创建一个新项目 + +1. 使用Visual Studio 2019 (16.4.0+)创建一个新的AspNet Core Web Application: + +![](images/create-new-aspnet-core-application-v2.png) + +2. 配置新的项目: + +![](images/select-empty-web-application-v2.png) + +3. 完成创建: + +![](images/create-aspnet-core-application.png) + + +## 安装 Volo.Abp.AspNetCore.Mvc 包 + +Volo.Abp.AspNetCore.Mvc是ABP集成AspNet Core MVC的包,请安装它到你项目中: + +```` +Install-Package Volo.Abp.AspNetCore.Mvc +```` + +## 创建ABP模块 + +ABP是一个模块化框架,它需要一个**启动 (根) 模块**继承自``AbpModule``: + +````C# +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Hosting; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Modularity; + +namespace BasicAspNetCoreApplication +{ + [DependsOn(typeof(AbpAspNetCoreMvcModule))] + public class AppModule : AbpModule + { + public override void OnApplicationInitialization( + ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Error"); + } + + app.UseStaticFiles(); + app.UseRouting(); + app.UseConfiguredEndpoints(); + } + } +} +```` + +``AppModule`` 是应用程序启动模块的好名称. + +ABP的包定义了这个模块类,模块可以依赖其它模块.在上面的代码中 ``AppModule`` 依赖于 ``AbpAspNetCoreMvcModule`` (模块存在于[Volo.Abp.AspNetCore.Mvc](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc)包中). 安装新的ABP的包后添加``DependsOn``是很常见的做法. + +我们在此模块类中配置ASP.NET Core管道,而不是Startup类中. + +### 启动类 + +接下来修改启动类集成ABP模块系统: + +````C# +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; + +namespace BasicAspNetCoreApplication +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app) + { + app.InitializeApplication(); + } + } +} + +```` + +``services.AddApplication()``添加了所有``AppModule``模块中定义的全部服务. + +``Configure``方法中的``app.InitializeApplication()``完成初始化并启动应用程序. + +## 运行应用程序! + +启动该应用,它将按预期运行. + +## 使用 Autofac 依赖注入框架 + +虽然AspNet Core的依赖注入(DI)系统适用于基本要求,但[Autofac](https://autofac.org/)提供了属性注入和方法拦截等高级功能,这些功能是ABP执行高级应用程序框架功能所必需的. + +用Autofac取代AspNet Core的DI系统并集成到ABP非常简单. + +1. 安装 [Volo.Abp.Autofac](https://www.nuget.org/packages/Volo.Abp.Autofac) 包 + +```` +Install-Package Volo.Abp.Autofac +```` + +2. 添加 ``AbpAutofacModule`` 依赖 + +````C# +[DependsOn(typeof(AbpAspNetCoreMvcModule))] +[DependsOn(typeof(AbpAutofacModule))] // 在模块上添加依赖AbpAutofacModule +public class AppModule : AbpModule +{ + ... +} +```` + +3. 修改``Program.cs``以使用Autofac: + +````C# +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace BasicAspNetCoreApplication +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac(); // 添加这一行 + } +} +```` + +## 源码 + +从[此处](https://github.com/abpframework/abp-samples/tree/master/BasicAspNetCoreApplication)获取本教程中创建的示例项目的源代码. diff --git a/docs/zh-Hans/How-To/Customize-SignIn-Manager.md b/docs/zh-Hans/How-To/Customize-SignIn-Manager.md index 73cbcd2ce7..eea0364e6e 100644 --- a/docs/zh-Hans/How-To/Customize-SignIn-Manager.md +++ b/docs/zh-Hans/How-To/Customize-SignIn-Manager.md @@ -38,7 +38,7 @@ public class CustomSignInManager : Microsoft.AspNetCore.Identity.SignInManager GetExternalLoginInfoAsync(string expectedXsrf = null) +public async override Task GetExternalLoginInfoAsync(string expectedXsrf = null) { var auth = await Context.AuthenticateAsync(Microsoft.AspNetCore.Identity.IdentityConstants.ExternalScheme); var items = auth?.Properties?.Items; diff --git a/docs/zh-Hans/Modules/Account.md b/docs/zh-Hans/Modules/Account.md new file mode 100644 index 0000000000..2e1c838f50 --- /dev/null +++ b/docs/zh-Hans/Modules/Account.md @@ -0,0 +1,36 @@ +# 账户模块 + +该模块提供必要的UI页面与组件使用户登录和注册到应用程序. + +> 文档正在更新 + +## 社交/外部登录 + +### 示例: Facebook 认证 + +按照[ASP.NET Core Facebook集成文档](https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/social/facebook-logins)向你应用程序添加Facebook登录. + +#### 添加NuGet包 + +添加[Microsoft.AspNetCore.Authentication.Facebook]包到你的项目. 基于你的架构,可能是 `.Web`,`.IdentityServer`(对于分层启动)或 `.Host` 项目. + +#### 配置提供程序 + +在你模块的 `ConfigureServices` 方法中使用 `.AddFacebook(...)` 扩展方法来配置客户端: + +````csharp +context.Services.AddAuthentication() + .AddFacebook(facebook => + { + facebook.AppId = "..."; + facebook.AppSecret = "..."; + facebook.Scope.Add("email"); + facebook.Scope.Add("public_profile"); + }); +```` + +> 最佳实践是使用 `appsettings.json` 或ASP.NET Core用户机密系统来存储你的凭据,而不是像这样硬编码值. 请参阅[微软](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins)文档了解如何使用用户机密. + +### Angular UI + +从v3.1开始,Angular UI使用授权码流程(作为最佳实践)通过重定向到MVC UI登录页面来对用户进行身份验证. 因此,即使你使用的是Angular UI,社交/外部登录集成也与上面说明的相同.并且可以开箱即用. \ No newline at end of file diff --git a/docs/zh-Hans/Modules/Blogging.md b/docs/zh-Hans/Modules/Blogging.md new file mode 100644 index 0000000000..cb82a640d5 --- /dev/null +++ b/docs/zh-Hans/Modules/Blogging.md @@ -0,0 +1 @@ +TODO... \ No newline at end of file diff --git a/docs/zh-Hans/Modules/Client-Simulation.md b/docs/zh-Hans/Modules/Client-Simulation.md new file mode 100644 index 0000000000..bc5d38e814 --- /dev/null +++ b/docs/zh-Hans/Modules/Client-Simulation.md @@ -0,0 +1,3 @@ +# Client Simulation Module + +TODO \ No newline at end of file diff --git a/docs/zh-Hans/Modules/Cms-Kit.md b/docs/zh-Hans/Modules/Cms-Kit.md new file mode 100644 index 0000000000..e13f1e585b --- /dev/null +++ b/docs/zh-Hans/Modules/Cms-Kit.md @@ -0,0 +1,3 @@ +# CMS Kit Module + +TODO \ No newline at end of file diff --git a/docs/zh-Hans/Modules/Feature-Management.md b/docs/zh-Hans/Modules/Feature-Management.md new file mode 100644 index 0000000000..cb82a640d5 --- /dev/null +++ b/docs/zh-Hans/Modules/Feature-Management.md @@ -0,0 +1 @@ +TODO... \ No newline at end of file diff --git a/docs/zh-Hans/Modules/Identity.md b/docs/zh-Hans/Modules/Identity.md index 5589fb367e..420b696a7c 100644 --- a/docs/zh-Hans/Modules/Identity.md +++ b/docs/zh-Hans/Modules/Identity.md @@ -2,7 +2,7 @@ 身份模块基于Microsoft Identity库用于管理[组织单元](Organization-Units.md), 角色, 用户和他们的权限. -参阅 [源码](https://github.com/abpframework/abp/tree/dev/modules/identity). 文档很快会被完善. +> 参阅 [源码](https://github.com/abpframework/abp/tree/dev/modules/identity). 文档很快会被完善. ## Identity安全日志 diff --git a/docs/zh-Hans/Modules/IdentityServer.md b/docs/zh-Hans/Modules/IdentityServer.md new file mode 100644 index 0000000000..cb82a640d5 --- /dev/null +++ b/docs/zh-Hans/Modules/IdentityServer.md @@ -0,0 +1 @@ +TODO... \ No newline at end of file diff --git a/docs/zh-Hans/Modules/Index.md b/docs/zh-Hans/Modules/Index.md index dab2f838df..656e5db96f 100644 --- a/docs/zh-Hans/Modules/Index.md +++ b/docs/zh-Hans/Modules/Index.md @@ -1,6 +1,6 @@ # 应用程序模块 -ABP是一个 **模块化的应用程序框架** 由十多个 **nuget packages** 组成. 它提供了一个完整的基础设施来构建你自己的应用程序模块,这些模块包含实体,服务,数据库集成,API,UI组件等. +ABP是一个 **模块化的应用程序框架** 由十多个 **NuGet & NPM packages** 组成. 它提供了一个完整的基础设施来构建你自己的应用程序模块,这些模块包含实体,服务,数据库集成,API,UI组件等. **有两种类型的模块.** 它们没有任何结构上的差异,只是按照功能和目地分类: @@ -9,20 +9,20 @@ ABP是一个 **模块化的应用程序框架** 由十多个 **nuget packages** ## 开源的应用程序模块 -有一些由ABP社区开发和维护的 **开源免费** 的应用程序模块: +有一些由ABP框架开发和维护的 **开源免费** 的应用程序模块: -* **Account**: 提供账户管理UI,并允许用户登录/注册应用程序. +* [**Account**](Account.md): 提供账户管理UI,并允许用户登录/注册应用程序. * [**Audit Logging**](Audit-Logging.md): 用于将审计日志持久化到数据库. -* **Background Jobs**: 用于在使用默认后台作业管理器时保存后台作业. -* **Blogging**: 用于创建精美的博客. ABP的[博客](https://blog.abp.io/) 就使用了此模块. +* [**Background Jobs**](Background-Jobs.md): 用于在使用默认后台作业管理器时保存后台作业. +* [**Blogging**](Blogging.md): 用于创建精美的博客. ABP的[博客](https://blog.abp.io/) 就使用了此模块. * [**Docs**](Docs.md): 用于创建技术文档页面. ABP的[文档](https://abp.io/documents/) 就使用了此模块. -* **Feature Management**: 用于保存和管理功能. +* [**Feature Management**](Feature-Management.md): 用于保存和管理功能. * [**Identity**](Identity.md): 基于Microsoft Identity管理组织单元,角色,用户和他们的权限. -* **Identity Server**: 集成了IdentityServer4. -* **Permission Management**: 用于保存权限. -* **Setting Management**: 用于保存设置. -* **Tenant Management**: 管理[多租户](../Multi-Tenancy.md)应用程序的租户. -* **Users**: 抽象用户, 因此其他模块可以依赖此模块而不是Identity模块. +* [**Identity Server**](IdentityServer.md): 集成了IdentityServer4. +* [**Permission Management**](Permission-Management.md): 用于保存权限. +* [**Setting Management**](Setting-Management.md): 用于保存设置. +* [**Tenant Management**](Tenant-Management.md): 管理[多租户](../Multi-Tenancy.md)应用程序的租户. +* [**Users**](Users.md): 抽象用户, 因此其他模块可以依赖此模块而不是Identity模块. * [**Virtual File Explorer**](Virtual-File-Explorer.md): 提供简单的UI查看[虚拟文件系统](../Virtual-File-System.md)中的文件. 模块化文档正在编写中. 请参阅[这个仓库](https://github.com/abpframework/abp/tree/master/modules)获取所有模块的源代码. diff --git a/docs/zh-Hans/Modules/Users.md b/docs/zh-Hans/Modules/Users.md new file mode 100644 index 0000000000..cb82a640d5 --- /dev/null +++ b/docs/zh-Hans/Modules/Users.md @@ -0,0 +1 @@ +TODO... \ No newline at end of file diff --git a/docs/zh-Hans/MongoDB.md b/docs/zh-Hans/MongoDB.md index c90b9b5740..2ceeb1e00c 100644 --- a/docs/zh-Hans/MongoDB.md +++ b/docs/zh-Hans/MongoDB.md @@ -160,7 +160,7 @@ public interface IBookRepository : IRepository 实现`IBookRepository`接口的例子: ```csharp -public class BookRepository : +public class BookRepository : MongoDbRepository, IBookRepository { @@ -200,9 +200,9 @@ context.Services.AddMongoDbContext(options => 当你想**重写基础仓储方法**时,这一点尤为重要.例如,你想要重写`DeleteAsync`方法,以便更有效的删除实体: ```csharp -public override async Task DeleteAsync( - Guid id, - bool autoSave = false, +public async override Task DeleteAsync( + Guid id, + bool autoSave = false, CancellationToken cancellationToken = default) { //TODO: 自定义实现删除方法 @@ -338,4 +338,4 @@ context.Services.AddMongoDbContext(options => }); ``` -这个例子中,`OtherMongoDbContext`实现了`IBookStoreMongoDbContext`.这个特性允许你在发开的时候使用多个MongoDbContext(每个模块一个),但是运行的时候只能使有一个MongoDbContext(实现所有MongoDbContexts的所有接口) \ No newline at end of file +这个例子中,`OtherMongoDbContext`实现了`IBookStoreMongoDbContext`.这个特性允许你在发开的时候使用多个MongoDbContext(每个模块一个),但是运行的时候只能使有一个MongoDbContext(实现所有MongoDbContexts的所有接口) diff --git a/docs/zh-Hans/Multi-Tenancy.md b/docs/zh-Hans/Multi-Tenancy.md index 863e9cfb4b..8e92d10673 100644 --- a/docs/zh-Hans/Multi-Tenancy.md +++ b/docs/zh-Hans/Multi-Tenancy.md @@ -127,13 +127,14 @@ namespace MyCompany.MyProject `MyCustomTenantResolveContributor`必须像下面这样实现**ITenantResolveContributor**接口: ````C# +using System.Threading.Tasks; using Volo.Abp.MultiTenancy; namespace MyCompany.MyProject { public class MyCustomTenantResolveContributor : ITenantResolveContributor { - public void Resolve(ITenantResolveContext context) + public override Task ResolveAsync(ITenantResolveContext context) { context.TenantIdOrName = ... //从其他地方获取租户id或租户名字... } diff --git a/docs/zh-Hans/Startup-Templates/Application.md b/docs/zh-Hans/Startup-Templates/Application.md index 58287cef5a..534a26d8fb 100644 --- a/docs/zh-Hans/Startup-Templates/Application.md +++ b/docs/zh-Hans/Startup-Templates/Application.md @@ -59,20 +59,6 @@ abp new Acme.BookStore -d mongodb ### 指定移动应用程序框架 -此模板支持以下移动应用程序框架: - -- `react-native`: React Native - -使用 `-m` (或 `--mobile`) 选项指定移动应用程序框架: - -````bash -abp new Acme.BookStore -m react-native -```` - -如果未指定,不会创建移动应用程序. - -### 指定移动应用程序框架 - 该模板支持以下移动应用程序框架: - `react-native`: React Native diff --git a/docs/zh-Hans/Startup-Templates/Index.md b/docs/zh-Hans/Startup-Templates/Index.md index fbc91c7549..268f51e98b 100644 --- a/docs/zh-Hans/Startup-Templates/Index.md +++ b/docs/zh-Hans/Startup-Templates/Index.md @@ -6,4 +6,5 @@ * [**app**](Application.md): 应用程序模板. * [**module**](Module.md): 模块/服务模板. -* [**console**](Console.md): 控制台模板. \ No newline at end of file +* [**console**](Console.md): 控制台模板. +* [**WPF**](WPF.md): WPF模板. diff --git a/docs/zh-Hans/Startup-Templates/WPF.md b/docs/zh-Hans/Startup-Templates/WPF.md new file mode 100644 index 0000000000..31a76eaa60 --- /dev/null +++ b/docs/zh-Hans/Startup-Templates/WPF.md @@ -0,0 +1,27 @@ +# WPF应用程序启动模板 + +此模板用于创建一个最小的依赖关系的ABP WPF应用程序项目. + +## 如何开始? + +首先,如果你没有安装[ABP CLI](../CLI.md),请先安装它: + +````bash +dotnet tool install -g Volo.Abp.Cli +```` + +在一个空文件夹使用 `abp new` 命令创建新解决方案: + +````bash +abp new Acme.MyWpfApp -t wpf +```` + +`Acme.MyWpfApp` 是解决方案的名称, 如*YourCompany.YourProduct*. 你可以使用单级或多级名称. + +## 解决方案结构 + +使用以上命令创建解决方案后,你会得到如下所示的解决方案: + +![basic-wpf-application-solution](../images/basic-wpf-application-solution.png) + +* `HelloWorldService` 是一个实现了 `ITransientDependency` 接口的示例服务. 它会自动注册到[依赖注入](../Dependency-Injection.md)系统. \ No newline at end of file diff --git a/docs/zh-Hans/Tutorials/Part-1.md b/docs/zh-Hans/Tutorials/Part-1.md index 99a7e3d9fb..e459c8b960 100644 --- a/docs/zh-Hans/Tutorials/Part-1.md +++ b/docs/zh-Hans/Tutorials/Part-1.md @@ -84,7 +84,7 @@ namespace Acme.BookStore.Books } ```` -* ABP为实体提供了两个基本的基类: `AggregateRoot`和`Entity`. **Aggregate Root**是**[领域驱动设计](./Domain-Driven-Design.md)** 概念之一. 可以视为直接查询和处理的根实体(请参阅[实体文档](./Entities.md)). +* ABP为实体提供了两个基本的基类: `AggregateRoot`和`Entity`. **Aggregate Root**是[**领域驱动设计**](./Domain-Driven-Design.md) 概念之一. 可以视为直接查询和处理的根实体(请参阅[实体文档](./Entities.md)). * `Book`实体继承了`AuditedAggregateRoot`,`AuditedAggregateRoot`类在`AggregateRoot`类的基础上添加了一些审计属性(`CreationTime`, `CreatorId`, `LastModificationTime` 等). ABP框架自动为你管理这些属性. * `Guid`是`Book`实体的主键类型. @@ -185,7 +185,7 @@ namespace Acme.BookStore.EntityFrameworkCore ### 添加数据迁移 -启动模板使用[EF Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/)创建和维护数据库架构. 打开菜单*工具 > NuGet包管理器*下的**程序包管理控制台 (PMC)**. +启动模板使用[EF Core Code First Migrations](https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/migrations/)创建和维护数据库架构. 打开菜单*工具 > NuGet包管理器*下的**程序包管理控制台 (PMC)**. ![Open Package Manager Console](images/bookstore-open-package-manager-console.png) @@ -201,7 +201,7 @@ Add-Migration "Created_Book_Entity" 在更新数据库之前,请阅读下面的部分了解如何将一些初始数据插入到数据库. -> 如果你使用其他IDE而不是Visual Studio, 你可以使用 [`dotnet-ef]`(https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#create-a-migration) 工具. +> 如果你使用其他IDE而不是Visual Studio, 你可以使用 [`dotnet-ef`](https://docs.microsoft.com/zh-cn/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#create-a-migration) 工具. {{end}} @@ -262,7 +262,7 @@ namespace Acme.BookStore } ``` -* 如果数据库中当前没有图书,则此代码使用 `IRepository`(默认为[repository](../Repositories.md)将两本书插入数据库. +* 如果数据库中当前没有图书,则此代码使用 `IRepository`(默认为[repository](../Repositories.md))将两本书插入数据库. ### 更新数据库 @@ -276,7 +276,7 @@ namespace Acme.BookStore 应用程序层由两个分离的项目组成: -* `Acme.BookStore.Application.Contracts 包含你的[DTO](../Data-Transfer-Objects.md)和[应用服务](../Application-Services.md)接口. +* `Acme.BookStore.Application.Contracts` 包含你的[DTO](../Data-Transfer-Objects.md)和[应用服务](../Application-Services.md)接口. * `Acme.BookStore.Application` 包含你的应用服务实现. 在本部分中,你将创建一个应用程序服务,使用ABP Framework的 `CrudAppService` 基类来获取,创建,更新和删除书籍. diff --git a/docs/zh-Hans/UI/AspNetCore/Customization-User-Interface.md b/docs/zh-Hans/UI/AspNetCore/Customization-User-Interface.md index c94c29d27f..44eb9b6e26 100644 --- a/docs/zh-Hans/UI/AspNetCore/Customization-User-Interface.md +++ b/docs/zh-Hans/UI/AspNetCore/Customization-User-Interface.md @@ -36,7 +36,7 @@ namespace Acme.BookStore.Web.Pages.Identity.Users { } - public override async Task OnPostAsync() + public async override Task OnPostAsync() { //TODO: Additional logic await base.OnPostAsync(); @@ -83,10 +83,10 @@ namespace Acme.BookStore.Web.Pages.Identity.Users public class MyLoginModel : LoginModel { public MyLoginModel( - IAuthenticationSchemeProvider schemeProvider, + IAuthenticationSchemeProvider schemeProvider, IOptions accountOptions ) : base( - schemeProvider, + schemeProvider, accountOptions) { diff --git a/docs/zh-Hans/docs-nav.json b/docs/zh-Hans/docs-nav.json index 9582711400..5ed50aebce 100644 --- a/docs/zh-Hans/docs-nav.json +++ b/docs/zh-Hans/docs-nav.json @@ -11,15 +11,43 @@ "text": "控制台应用程序", "path": "Startup-Templates/Console.md" }, + { + "text": "WPF应用程序", + "path": "Startup-Templates/WPF.md" + }, { "text": "空Web应用程序", "path": "Getting-Started-AspNetCore-Application.md" } ] }, + { + "text": "启动模板", + "items": [ + { + "text": "概述", + "path": "Startup-Templates/Index.md" + }, + { + "text": "应用程序", + "path": "Startup-Templates/Application.md" + }, + { + "text": "模块", + "path": "Startup-Templates/Module.md" + }, + { + "text": "控制台", + "path": "Startup-Templates/Console.md" + }, + { + "text": "WPF", + "path": "Startup-Templates/WPF.md" + } + ] + }, { "text": "教程", - "path": "Tutorials/Index.md", "items": [ { "text": "应用开发", @@ -37,29 +65,10 @@ "path": "Tutorials/Part-3.md" } ] - } - ] - }, - { - "text": "指南", - "items": [ + }, { - "text": "自定义应用模块", - "path": "Customizing-Application-Modules-Guide.md", - "items": [ - { - "text": "扩展实体", - "path": "Customizing-Application-Modules-Extending-Entities.md" - }, - { - "text": "重写服务", - "path": "Customizing-Application-Modules-Overriding-Services.md" - }, - { - "text": "重写用户界面", - "path": "Customizing-Application-Modules-Overriding-User-Interface.md" - } - ] + "text": "社区文章", + "path": "https://community.abp.io/articles" }, { "text": "从ASP.NET Boilerplate迁移", @@ -67,19 +76,6 @@ } ] }, - { - "text": "CLI", - "path": "CLI.md" - }, - { - "text": "认证", - "items": [ - { - "text": "社交/外部登录", - "path": "Authentication/Social-External-Logins.md" - } - ] - }, { "text": "基础知识", "items": [ @@ -101,10 +97,6 @@ } ] }, - { - "text": "虚拟文件系统", - "path": "Virtual-File-System.md" - }, { "text": "本地化", "path": "Localization.md" @@ -135,17 +127,13 @@ "text": "日志", "path": "Logging.md" }, - { - "text": "审计日志", - "path": "Audit-Logging.md" - }, { "text": "设置管理", "path": "Settings.md" }, { - "text": "数据过滤", - "path": "Data-Filtering.md" + "text": "连接字符串", + "path": "Connection-Strings.md" }, { "text": "对象扩展", @@ -154,39 +142,88 @@ ] }, { - "text": "事件总线", - "items": [ + "text": "基础设施", + "items":[ { - "text": "概述", - "path": "Event-Bus.md" - }, - { - "text": "本地 Event Bus", - "path": "Local-Event-Bus.md" + "text": "后台服务", + "items": [ + { + "text": "后台作业", + "path": "Background-Jobs.md", + "items": [ + { + "text": "Hangfire 集成", + "path": "Background-Jobs-Hangfire.md" + }, + { + "text": "RabbitMQ 集成", + "path": "Background-Jobs-RabbitMq.md" + }, + { + "text": "Quartz 集成", + "path": "Background-Jobs-Quartz.md" + } + ] + }, + { + "text": "后台工作者", + "path": "Background-Workers.md", + "items": [ + { + "text": "Quartz 集成", + "path": "Background-Workers-Quartz.md" + } + ] + } + ] }, { - "text": "分布式 Event Bus", - "path": "Distributed-Event-Bus.md", + "text": "事件总线", "items": [ { - "text": "RabbitMQ 集成", - "path": "Distributed-Event-Bus-RabbitMQ-Integration.md" + "text": "概述", + "path": "Event-Bus.md" }, { - "text": "Kafka 集成", - "path": "Distributed-Event-Bus-Kafka-Integration.md" + "text": "本地 Event Bus", + "path": "Local-Event-Bus.md" }, { - "text": "Rebus 集成", - "path": "Distributed-Event-Bus-Rebus-Integration.md" + "text": "分布式 Event Bus", + "path": "Distributed-Event-Bus.md", + "items": [ + { + "text": "RabbitMQ 集成", + "path": "Distributed-Event-Bus-RabbitMQ-Integration.md" + }, + { + "text": "Kafka 集成", + "path": "Distributed-Event-Bus-Kafka-Integration.md" + }, + { + "text": "Rebus 集成", + "path": "Distributed-Event-Bus-Rebus-Integration.md" + } + ] } ] - } - ] - }, - { - "text": "服务", - "items": [ + }, + { + "text": "种子数据", + "path": "Data-Seeding.md" + }, + { + "text": "虚拟文件系统", + "path": "Virtual-File-System.md" + }, + { + "text": "审计日志", + "path": "Audit-Logging.md" + }, + { + "text": "数据过滤", + "path": "Data-Filtering.md" + }, { "text": "当前用户", "path": "CurrentUser.md" @@ -266,22 +303,41 @@ ] }, { - "text": "多租户", - "path": "Multi-Tenancy.md" - }, - { - "text": "模块开发", - "items": [ - { - "text": "基础", - "path": "Module-Development-Basics.md" - }, + "text": "架构", + "items":[ { - "text": "模块插件" - }, - { - "text": "最佳实践", - "path": "Best-Practices/Index.md" + "text": "模块化", + "items": [ + { + "text": "基础", + "path": "Module-Development-Basics.md" + }, + { + "text": "模块插件" + }, + { + "text": "自定义应用模块", + "path": "Customizing-Application-Modules-Guide.md", + "items": [ + { + "text": "扩展实体", + "path": "Customizing-Application-Modules-Extending-Entities.md" + }, + { + "text": "重写服务", + "path": "Customizing-Application-Modules-Overriding-Services.md" + }, + { + "text": "重写用户界面", + "path": "Customizing-Application-Modules-Overriding-User-Interface.md" + } + ] + }, + { + "text": "最佳实践", + "path": "Best-Practices/Index.md" + } + ] } ] }, @@ -331,6 +387,14 @@ "path": "Unit-Of-Work.md" } ] + }, + { + "text": "多租户", + "path": "Multi-Tenancy.md" + }, + { + "text": "微服务架构", + "path": "Microservice-Architecture.md" } ] }, @@ -512,58 +576,45 @@ "path": "Data-Access.md" }, { - "text": "连接字符串", - "path": "Connection-Strings.md" - }, - { - "text": "数据库提供程序", + "text": "Entity Framework Core", + "path": "Entity-Framework-Core.md", "items": [ { - "text": "Entity Framework Core", - "path": "Entity-Framework-Core.md", - "items": [ + "text": "数据库迁移", + "path": "Entity-Framework-Core-Migrations.md" + }, + { + + "text": "切换DMBS", + "path": "Entity-Framework-Core-Other-DBMS.md", + "items":[ { - "text": "数据库迁移", - "path": "Entity-Framework-Core-Migrations.md" + "text": "到MySql", + "path": "Entity-Framework-Core-MySQL.md" }, { - - "text": "切换DMBS", - "path": "Entity-Framework-Core-Other-DBMS.md", - "items":[ - { - "text": "到MySql", - "path": "Entity-Framework-Core-MySQL.md" - }, - { - "text": "到PostgreSQL", - "path": "Entity-Framework-Core-PostgreSQL.md" - }, - { - "text": " Oracle", - "path": "Entity-Framework-Core-Oracle.md" - }, - { - "text": "到SQLite", - "path": "Entity-Framework-Core-SQLite.md" - } - ] + "text": "到PostgreSQL", + "path": "Entity-Framework-Core-PostgreSQL.md" + }, + { + "text": " Oracle", + "path": "Entity-Framework-Core-Oracle.md" + }, + { + "text": "到SQLite", + "path": "Entity-Framework-Core-SQLite.md" } ] - }, - { - "text": "MongoDB", - "path": "MongoDB.md" - }, - { - "text": "Dapper", - "path": "Dapper.md" } ] }, { - "text": "种子数据", - "path": "Data-Seeding.md" + "text": "MongoDB", + "path": "MongoDB.md" + }, + { + "text": "Dapper", + "path": "Dapper.md" } ] }, @@ -577,107 +628,128 @@ ] }, { - "text": "后台服务", + "text": "示例", "items": [ { - "text": "后台作业", - "path": "Background-Jobs.md", - "items": [ - { - "text": "Hangfire 集成", - "path": "Background-Jobs-Hangfire.md" - }, - { - "text": "RabbitMQ 集成", - "path": "Background-Jobs-RabbitMq.md" - }, - { - "text": "Quartz 集成", - "path": "Background-Jobs-Quartz.md" - } - ] + "text": "所有示例", + "path": "Samples/Index.md" }, { - "text": "后台工作者", - "path": "Background-Workers.md", - "items": [ - { - "text": "Quartz 集成", - "path": "Background-Workers-Quartz.md" - } - ] + "text": "微服务示例", + "path": "Samples/Microservice-Demo.md" } ] - }, + }, { - "text": "启动模板", - "items": [ + "text": "应用模块", + "items":[ { "text": "概述", - "path": "Startup-Templates/Index.md" + "path": "Modules/Index.md" }, { - "text": "应用程序", - "path": "Startup-Templates/Application.md" + "text": "账户", + "path": "Modules/Account.md" }, { - "text": "模块", - "path": "Startup-Templates/Module.md" + "text": "审计日志", + "path": "Modules/Audit-Logging.md" }, { - "text": "控制台", - "path": "Startup-Templates/Console.md" + "text": "后台作业", + "path": "Modules/Background-Jobs.md" + }, + { + "text": "博客", + "path": "Modules/Blogging.md" + }, + { + "text": "客户端模拟", + "path": "Modules/Client-Simulation.md" + }, + { + "text": "CMS Kit", + "path": "Modules/Cms-Kit.md" + }, + { + "text": "文档", + "path": "Modules/Docs.md" + }, + { + "text": "功能管理", + "path": "Modules/Feature-Management.md" + }, + { + "text": "Identity", + "path": "Modules/Identity.md" + }, + { + "text": "IdentityServer", + "path": "Modules/IdentityServer.md" + }, + { + "text": "权限管理", + "path": "Modules/Permission-Management.md" + }, + { + "text": "设置管理", + "path": "Modules/Setting-Management.md" + }, + { + "text": "租户管理", + "path": "Modules/Tenant-Management.md" + }, + { + "text": "用户", + "path": "Modules/Users.md" + }, + { + "text": "虚拟文件浏览器", + "path": "Modules/Virtual-File-Explorer.md" } ] }, { - "text": "示例", + "text": "发布信息", "items": [ { - "text": "所有示例", - "path": "Samples/Index.md" + "text": "升级", + "path": "Upgrading.md" }, { - "text": "微服务示例", - "path": "Samples/Microservice-Demo.md" + "text": "官方包", + "path": "https://abp.io/packages" + }, + { + "text": "预览版本", + "path": "Previews.md" + }, + { + "text": "每日构建", + "path": "Nightly-Builds.md" + }, + { + "text": "路线图", + "path": "Road-Map.md" } ] }, { - "text": "应用模块", - "path": "Modules/Index.md" - }, - { - "text": "微服务架构", - "path": "Microservice-Architecture.md" - }, - { - "text": "预览版本", - "path": "Previews.md" - }, - { - "text": "每日构建", - "path": "Nightly-Builds.md" - }, - { - "text": "路线图", - "path": "Road-Map.md" - }, - { - "text": "升级", - "path": "Upgrading.md" + "text": "参考", + "items": [ + { + "text": "CLI", + "path": "CLI.md" + }, + { + "text": "API文档", + "path": "{ApiDocumentationUrl}" + } + ] }, { "text": "贡献指南", "path": "Contribution/Index.md" - }, - { - "text": "API文档", - "path": "{ApiDocumentationUrl}" - }, - { - "text": "官方包", - "path": "https://abp.io/packages" } ] } diff --git a/docs/zh-Hans/images/basic-wpf-application-solution.png b/docs/zh-Hans/images/basic-wpf-application-solution.png new file mode 100644 index 0000000000..5943acd93f Binary files /dev/null and b/docs/zh-Hans/images/basic-wpf-application-solution.png differ diff --git a/framework/.editorconfig b/framework/.editorconfig deleted file mode 100644 index 9f20b90112..0000000000 --- a/framework/.editorconfig +++ /dev/null @@ -1,131 +0,0 @@ -# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\Projects\Volosoft\abp\framework codebase based on best match to current usage at 2.10.2020. -# You can modify the rules from these initially generated values to suit your own policies -# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference -[*.cs] - - -#Core editorconfig formatting - indentation - -#use soft tabs (spaces) for indentation -indent_style = space - -#Formatting - indentation options - -#indent switch case contents. -csharp_indent_case_contents = true -#indent switch labels -csharp_indent_switch_labels = true - -#Formatting - new line options - -#place catch statements on a new line -csharp_new_line_before_catch = true -#place else statements on a new line -csharp_new_line_before_else = true -#require members of object intializers to be on separate lines -csharp_new_line_before_members_in_object_initializers = true -#require braces to be on a new line for accessors, methods, lambdas, object_collection_array_initializers, control_blocks, types, and properties (also known as "Allman" style) -csharp_new_line_before_open_brace = accessors, methods, lambdas, object_collection_array_initializers, control_blocks, types, properties - -#Formatting - organize using options - -#sort System.* using directives alphabetically, and place them before other usings -dotnet_sort_system_directives_first = true - -#Formatting - spacing options - -csharp_space_after_cast = false -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_after_comma = true -csharp_space_after_dot = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_after_semicolon_in_for_statement = true -csharp_space_around_binary_operators = before_and_after -csharp_space_around_declaration_statements = false -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_before_comma = false -csharp_space_before_dot = false -csharp_space_before_open_square_brackets = false -csharp_space_before_semicolon_in_for_statement = false -csharp_space_between_empty_square_brackets = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -csharp_space_between_method_call_parameter_list_parentheses = false -csharp_space_between_method_declaration_empty_parameter_list_parentheses = false -csharp_space_between_method_declaration_name_and_open_parenthesis = false -csharp_space_between_method_declaration_parameter_list_parentheses = false -csharp_space_between_parentheses = false -csharp_space_between_square_brackets = false - -#Formatting - wrapping options - -#leave code block on single line -csharp_preserve_single_line_blocks = true - -#Style - Code block preferences - -#prefer curly braces even for one line of code -csharp_prefer_braces = true:suggestion - -#Style - expression bodied member options - -#prefer block bodies for constructors -csharp_style_expression_bodied_constructors = false:suggestion -#prefer block bodies for methods -csharp_style_expression_bodied_methods = false:suggestion -#prefer expression-bodied members for properties -csharp_style_expression_bodied_properties = true:suggestion - -#Style - expression level options - -#prefer out variables to be declared inline in the argument list of a method call when possible -csharp_style_inlined_variable_declaration = true:suggestion -#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them -dotnet_style_predefined_type_for_member_access = true:suggestion - -#Style - Expression-level preferences - -#prefer default over default(T) -csharp_prefer_simple_default_expression = true:suggestion -#prefer objects to be initialized using object initializers when possible -dotnet_style_object_initializer = true:suggestion -#prefer inferred tuple element names -dotnet_style_prefer_inferred_tuple_names = true:suggestion - -#Style - implicit and explicit types - -#prefer var over explicit type in all cases, unless overridden by another code style rule -csharp_style_var_elsewhere = true:suggestion -#prefer var is used to declare variables with built-in system types such as int -csharp_style_var_for_built_in_types = true:suggestion -#prefer var when the type is already mentioned on the right-hand side of a declaration expression -csharp_style_var_when_type_is_apparent = true:suggestion - -#Style - language keyword and framework type options - -#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them -dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion - -#Style - modifier options - -#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods. -dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion - -#Style - Modifier preferences - -#when this rule is set to a list of modifiers, prefer the specified ordering. -csharp_preferred_modifier_order = public,protected,private,virtual,async,static,override,readonly,abstract:suggestion - -#Style - Pattern matching - -#prefer pattern matching instead of is expression with type casts -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion - -#Style - qualification options - -#prefer fields not to be prefaced with this. or Me. in Visual Basic -dotnet_style_qualification_for_field = false:suggestion -#prefer methods not to be prefaced with this. or Me. in Visual Basic -dotnet_style_qualification_for_method = false:suggestion -#prefer properties not to be prefaced with this. or Me. in Visual Basic -dotnet_style_qualification_for_property = false:suggestion diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index e922ac7f8d..963472ada8 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -347,12 +347,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Autofac.WebAssembl EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.AspNetCore.Authentication.OpenIdConnect", "src\Volo.Abp.AspNetCore.Authentication.OpenIdConnect\Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj", "{DEFE3DB2-EA4F-4F90-87FC-B25D64427BC5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Rebus", "src\Volo.Abp.EventBus.Rebus\Volo.Abp.EventBus.Rebus.csproj", "{F689967F-1EF1-4D75-8BA4-2F2F3506B1F3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.EventBus.Rebus", "src\Volo.Abp.EventBus.Rebus\Volo.Abp.EventBus.Rebus.csproj", "{F689967F-1EF1-4D75-8BA4-2F2F3506B1F3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.ExceptionHandling", "src\Volo.Abp.ExceptionHandling\Volo.Abp.ExceptionHandling.csproj", "{B9D1ADCB-D552-4626-A1F1-78FF72C1E822}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.ExceptionHandling", "src\Volo.Abp.ExceptionHandling\Volo.Abp.ExceptionHandling.csproj", "{B9D1ADCB-D552-4626-A1F1-78FF72C1E822}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.AspNetCore.Components", "src\Volo.Abp.AspNetCore.Components\Volo.Abp.AspNetCore.Components.csproj", "{89840441-5A3A-4FD7-9CB4-E5B52FAEF72A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Swashbuckle", "src\Volo.Abp.Swashbuckle\Volo.Abp.Swashbuckle.csproj", "{DD9519E0-5A68-48DC-A051-7BF2AC922F3E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Json.Tests", "test\Volo.Abp.Json.Tests\Volo.Abp.Json.Tests.csproj", "{00D07595-993C-40FC-BD90-0DD6331414D3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Tests", "test\Volo.Abp.Http.Tests\Volo.Abp.Http.Tests.csproj", "{A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1047,10 +1053,22 @@ Global {B9D1ADCB-D552-4626-A1F1-78FF72C1E822}.Debug|Any CPU.Build.0 = Debug|Any CPU {B9D1ADCB-D552-4626-A1F1-78FF72C1E822}.Release|Any CPU.ActiveCfg = Release|Any CPU {B9D1ADCB-D552-4626-A1F1-78FF72C1E822}.Release|Any CPU.Build.0 = Release|Any CPU + {89840441-5A3A-4FD7-9CB4-E5B52FAEF72A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89840441-5A3A-4FD7-9CB4-E5B52FAEF72A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89840441-5A3A-4FD7-9CB4-E5B52FAEF72A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89840441-5A3A-4FD7-9CB4-E5B52FAEF72A}.Release|Any CPU.Build.0 = Release|Any CPU {DD9519E0-5A68-48DC-A051-7BF2AC922F3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DD9519E0-5A68-48DC-A051-7BF2AC922F3E}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD9519E0-5A68-48DC-A051-7BF2AC922F3E}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD9519E0-5A68-48DC-A051-7BF2AC922F3E}.Release|Any CPU.Build.0 = Release|Any CPU + {00D07595-993C-40FC-BD90-0DD6331414D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00D07595-993C-40FC-BD90-0DD6331414D3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00D07595-993C-40FC-BD90-0DD6331414D3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00D07595-993C-40FC-BD90-0DD6331414D3}.Release|Any CPU.Build.0 = Release|Any CPU + {A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1228,7 +1246,10 @@ Global {DEFE3DB2-EA4F-4F90-87FC-B25D64427BC5} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {F689967F-1EF1-4D75-8BA4-2F2F3506B1F3} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {B9D1ADCB-D552-4626-A1F1-78FF72C1E822} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {89840441-5A3A-4FD7-9CB4-E5B52FAEF72A} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {DD9519E0-5A68-48DC-A051-7BF2AC922F3E} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {00D07595-993C-40FC-BD90-0DD6331414D3} = {447C8A77-E5F0-4538-8687-7383196D04EA} + {A37BFEB5-7C57-4CDC-93B8-B5CE4BB9ACE1} = {447C8A77-E5F0-4538-8687-7383196D04EA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo.Abp.AspNetCore.Authentication.JwtBearer.csproj b/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo.Abp.AspNetCore.Authentication.JwtBearer.csproj index ca9a9af864..f138f313c2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo.Abp.AspNetCore.Authentication.JwtBearer.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Volo.Abp.AspNetCore.Authentication.JwtBearer.csproj @@ -4,7 +4,7 @@ - netcoreapp3.1 + net5.0 Volo.Abp.AspNetCore.Authentication.JwtBearer Volo.Abp.AspNetCore.Authentication.JwtBearer $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; @@ -19,7 +19,7 @@ - + diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo.Abp.AspNetCore.Authentication.OAuth.csproj b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo.Abp.AspNetCore.Authentication.OAuth.csproj index ae032e5b9e..18e9a271dc 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo.Abp.AspNetCore.Authentication.OAuth.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OAuth/Volo.Abp.AspNetCore.Authentication.OAuth.csproj @@ -4,7 +4,7 @@ - netcoreapp3.1 + net5.0 Volo.Abp.AspNetCore.Authentication.OAuth Volo.Abp.AspNetCore.Authentication.OAuth $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj index 9a09e89c5d..84ecc6a1bf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj @@ -4,12 +4,12 @@ - netcoreapp3.1 + net5.0 - + diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeBundleContributor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeBundleContributor.cs new file mode 100644 index 0000000000..edef97eb52 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/BasicThemeBundleContributor.cs @@ -0,0 +1,17 @@ +using Volo.Abp.Bundling; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme +{ + public class BasicThemeBundleContributor : IBundleContributor + { + public void AddScripts(BundleContext context) + { + + } + + public void AddStyles(BundleContext context) + { + context.Add("_content/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/libs/abp/css/theme.css"); + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/Branding.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/Branding.razor new file mode 100644 index 0000000000..4810320664 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/Branding.razor @@ -0,0 +1,3 @@ +@using Volo.Abp.Ui.Branding +@inject IBrandingProvider BrandingProvider +@BrandingProvider.AppName diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor new file mode 100644 index 0000000000..31090ac092 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor @@ -0,0 +1,48 @@ +@using Volo.Abp.UI.Navigation +@{ + var elementId = MenuItem.ElementId ?? "MenuItem_" + MenuItem.Name.Replace(".", "_"); + var cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass; + var disabled = MenuItem.IsDisabled ? "disabled" : string.Empty; + var url = string.IsNullOrEmpty(MenuItem.Url) ? "#" : MenuItem.Url; +} +@if (MenuItem.IsLeaf) +{ + if (MenuItem.Url != null) + { + + } +} +else +{ + +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor.cs new file mode 100644 index 0000000000..d0ff42879c --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/FirstLevelNavMenuItem.razor.cs @@ -0,0 +1,38 @@ +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Routing; +using Volo.Abp.UI.Navigation; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic +{ + public partial class FirstLevelNavMenuItem : IDisposable + { + [Inject] private NavigationManager NavigationManager { get; set; } + + [Parameter] + public ApplicationMenuItem MenuItem { get; set; } + + public bool IsSubMenuOpen { get; set; } + + protected override void OnInitialized() + { + NavigationManager.LocationChanged += OnLocationChanged; + } + + private void ToggleSubMenu() + { + IsSubMenuOpen = !IsSubMenuOpen; + } + + public void Dispose() + { + NavigationManager.LocationChanged -= OnLocationChanged; + } + + private void OnLocationChanged(object sender, LocationChangedEventArgs e) + { + IsSubMenuOpen = false; + StateHasChanged(); + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor index 8c7b348f7d..6b93618f44 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor @@ -5,23 +5,23 @@ @inject IJSRuntime JsRuntime @if (_otherLanguages != null && _otherLanguages.Any()) { - - + + @_currentLanguage.DisplayName - - + + @foreach (var language in _otherLanguages) { - @language.DisplayName + @language.DisplayName } - - + + } @code { private IReadOnlyList _otherLanguages; private LanguageInfo _currentLanguage; - protected override async Task OnInitializedAsync() + protected async override Task OnInitializedAsync() { var selectedLanguageName = await JsRuntime.InvokeAsync( "localStorage.getItem", diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs index 3238483cfb..494eca34ab 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs @@ -13,7 +13,7 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic protected ApplicationMenu Menu { get; set; } - protected override async Task OnInitializedAsync() + protected async override Task OnInitializedAsync() { Menu = await MenuManager.GetAsync(StandardMenus.User); diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor index 6954057142..e85e899123 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor @@ -1,15 +1,13 @@ @inherits LayoutComponentBase -@using Volo.Abp.Ui.Branding -@inject IBrandingProvider BrandingProvider
+ @Body +
diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor.cs new file mode 100644 index 0000000000..2464275c2c --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/MainLayout.razor.cs @@ -0,0 +1,34 @@ +using System; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Routing; + +namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic +{ + public partial class MainLayout : IDisposable + { + [Inject] private NavigationManager NavigationManager { get; set; } + + private bool IsCollapseShown { get; set; } + + protected override void OnInitialized() + { + NavigationManager.LocationChanged += OnLocationChanged; + } + + private void ToggleCollapse() + { + IsCollapseShown = !IsCollapseShown; + } + + public void Dispose() + { + NavigationManager.LocationChanged -= OnLocationChanged; + } + + private void OnLocationChanged(object sender, LocationChangedEventArgs e) + { + IsCollapseShown = false; + StateHasChanged(); + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor index c3ada520dc..b35ec8ba2e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor @@ -2,50 +2,6 @@ { foreach (var menuItem in Menu.Items) { - var elementId = menuItem.ElementId ?? "MenuItem_" + menuItem.Name.Replace(".", "_"); - var cssClass = string.IsNullOrEmpty(menuItem.CssClass) ? string.Empty : menuItem.CssClass; - var disabled = menuItem.IsDisabled ? "disabled" : string.Empty; - var url = string.IsNullOrEmpty(menuItem.Url) ? "#" : menuItem.Url; - if (menuItem.IsLeaf) - { - if (menuItem.Url != null) - { - - } - } - else - { - - } + } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor.cs index e47603e163..1779d73d28 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenu.razor.cs @@ -6,22 +6,14 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic { public partial class NavMenu { - [Inject] protected IMenuManager MenuManager { get; set; } + [Inject] + protected IMenuManager MenuManager { get; set; } protected ApplicationMenu Menu { get; set; } - private bool collapseNavMenu = true; - - private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; - - protected override async Task OnInitializedAsync() + protected async override Task OnInitializedAsync() { Menu = await MenuManager.GetAsync(StandardMenus.Main); } - - private void ToggleNavMenu() - { - collapseNavMenu = !collapseNavMenu; - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor index 5eea07ea8f..ede8a54415 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor @@ -1,8 +1,8 @@  diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor.cs index 6fddf263b3..33044282f9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavToolbar.razor.cs @@ -12,7 +12,7 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic private List ToolbarItemRenders { get; set; } = new List(); - protected override async Task OnInitializedAsync() + protected async override Task OnInitializedAsync() { var toolbar = await ToolbarManager.GetAsync(StandardToolbars.Main); diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenuItem.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor similarity index 82% rename from framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenuItem.razor rename to framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor index 338ce7b464..4e75e26b50 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/NavMenuItem.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/SecondLevelNavMenuItem.razor @@ -24,7 +24,7 @@ else {