Created at 9pm, Feb 24
furkanSoftware Development
1
Implementing Domain Driven Design
JZM-oQLydvo3gvEJ2e9sjq1XlGwmg0c3bS_i4lPm_D8
File Type
PDF
Entry Count
94
Embed. Model
jina_embeddings_v2_base_en
Index Type
hnsw

Implementing Domain Driven Design - Halil İbrahim Kalkan

Implementing Domain Driven Design ABP's Exception Handling system solves these and similar problems. Example: Throwing a business exception with 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 le to nd the localized message. Now, we can change the ReOpen method as shown below: 48 Implementing Domain Driven Design
id: 24ead4ba4b8383ce2ae42ec6b066d5eb - page: 49
Use constants instead of magic strings. And add an entry to the localization resource like below: 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 dening a specialized IssueStateException. The result will be same. See the exception handling document for all the details. 49 Implementing Domain Driven Design
id: 597ea0c09f25f53ade9455216006d647 - page: 50
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 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. 50
id: 673a8cdbad920cc54cd8b9e208e3d3a2 - page: 51
Implementing Domain Driven Design Example: Business Rule: Can not assign more than 3 open issues to a user concurrently 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. 51
id: 9bf0d14b2ef83b98a4eb0bf588394eae - page: 52
How to Retrieve?
# Search

curl -X POST "https://search.dria.co/hnsw/search" \
-H "x-api-key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"rerank": true, "top_n": 10, "contract_id": "JZM-oQLydvo3gvEJ2e9sjq1XlGwmg0c3bS_i4lPm_D8", "query": "What is alexanDRIA library?"}'
        
# Query

curl -X POST "https://search.dria.co/hnsw/query" \
-H "x-api-key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"vector": [0.123, 0.5236], "top_n": 10, "contract_id": "JZM-oQLydvo3gvEJ2e9sjq1XlGwmg0c3bS_i4lPm_D8", "level": 2}'