diff --git a/docs/en/tutorials/modular-crm/images/sql-server-orders-table-content.png b/docs/en/tutorials/modular-crm/images/sql-server-orders-table-content.png index 3e3794e536..8e4cb9e923 100644 Binary files a/docs/en/tutorials/modular-crm/images/sql-server-orders-table-content.png and b/docs/en/tutorials/modular-crm/images/sql-server-orders-table-content.png differ diff --git a/docs/en/tutorials/modular-crm/images/visual-studio-order-reporting-app-service-impl.png b/docs/en/tutorials/modular-crm/images/visual-studio-order-reporting-app-service-impl.png new file mode 100644 index 0000000000..d38e66365e Binary files /dev/null and b/docs/en/tutorials/modular-crm/images/visual-studio-order-reporting-app-service-impl.png differ diff --git a/docs/en/tutorials/modular-crm/part-05.md b/docs/en/tutorials/modular-crm/part-05.md index a54cfcf88f..4f4cb68f5e 100644 --- a/docs/en/tutorials/modular-crm/part-05.md +++ b/docs/en/tutorials/modular-crm/part-05.md @@ -56,12 +56,12 @@ Now, you can return your IDE and add an `Order` class to the `ModularCrm.Orderin ````csharp using System; -using Volo.Abp.Domain.Entities; using ModularCrm.Ordering.Contracts.Enums; +using Volo.Abp.Domain.Entities.Auditing; namespace ModularCrm.Ordering.Entities { - public class Order : AggregateRoot + public class Order : CreationAuditedAggregateRoot { public Guid ProductId { get; set; } public string CustomerName { get; set; } @@ -70,7 +70,7 @@ namespace ModularCrm.Ordering.Entities } ```` -We are allowing to place only a single product within an order. In a real-world application, the `Order` entity would be much more complex. However, the complexity of the `Order` entity doesn't effect modularity, so we keep it simple to focus on modularity in this tutorial. +We are allowing to place only a single product within an order. In a real-world application, the `Order` entity would be much more complex. However, the complexity of the `Order` entity doesn't effect modularity, so we keep it simple to focus on modularity in this tutorial. We are inheriting from the [`CreationAuditedAggregateRoot` class](../../framework/architecture/domain-driven-design/entities.md) since I want to know when an order has been created and who has created it. ### Adding an `OrderState` Enumeration diff --git a/docs/en/tutorials/modular-crm/part-06.md b/docs/en/tutorials/modular-crm/part-06.md index 1f4d7392cd..80d464248a 100644 --- a/docs/en/tutorials/modular-crm/part-06.md +++ b/docs/en/tutorials/modular-crm/part-06.md @@ -547,7 +547,7 @@ namespace ModularCrm.Orders // Product data public Guid ProductId { get; set; } - public Guid ProductName { get; set; } + public string ProductName { get; set; } } } ```` @@ -560,4 +560,63 @@ After adding these files, the final folder structure should be like that: ##### Implementing the `OrderReportingAppService` Class +Create an `Orders` folder inside of the `ModularCrm.Application` project and add a class named `OrderReportingAppService` inside it. The final folder structure should be like that: + +![visual-studio-order-reporting-app-service-impl](images/visual-studio-order-reporting-app-service-impl.png) + +Open the `OrderReportingAppService.cs` file and change its content by the following code block: + +````csharp +using ModularCrm.Ordering.Entities; +using ModularCrm.Products; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; + +namespace ModularCrm.Orders +{ + public class OrderReportingAppService : + ModularCrmAppService, + IOrderReportingAppService + { + private readonly IRepository _orderRepository; + private readonly IRepository _productRepository; + + public OrderReportingAppService( + IRepository orderRepository, + IRepository productRepository) + { + _orderRepository = orderRepository; + _productRepository = productRepository; + } + + public async Task> GetLatestOrders() + { + var orders = await _orderRepository.GetQueryableAsync(); + var products = await _productRepository.GetQueryableAsync(); + + var latestOrders = (from order in orders + join product in products on order.ProductId equals product.Id + orderby order.CreationTime descending + select new OrderReportDto + { + OrderId = order.Id, + CustomerName = order.CustomerName, + State = order.State, + ProductId = product.Id, + ProductName = product.Name + }) + .Take(10) + .ToList(); + + return latestOrders; + } + } +} +```` + + + s