IntentArchitect / Support

A repository dedicated to handling issues and support queries
3 stars 0 forks source link

Solution renaming #89

Closed yaasierp closed 2 months ago

yaasierp commented 2 months ago

Ask a question

Hi

How do i rename a solution?

Regards

JonathanLydall commented 2 months ago

Hello @yaasierp,

If you're asking about an Intent Architect solution:

This can be done through the Settings screen:

If you're asking about the Visual Studio solution:

Please let me know if this answers your question and don't hesitate to reach out again should you have any further comments or questions.

yaasierp commented 2 months ago

Hi JonathanLydall

Thanks for the help previously.

My next question is, can I add/create seed data in IA for my domain objects or should that be done in the VS solution as part of the Persistence/Configuration/ProductConfiguration?

Example Product.Hasdata( new Product { Name="Product 1", Price="10.00"});

I want this data to be available in the IM database and use it in my apis.

Regards Yaasier

dandrejvv commented 2 months ago

Hi @yaasierp

We don't have any modules at this time for modelling and generating seed data, so it will need to be done in Visual Studio.

Our patterns do generate a "ConfigureModel" method in the ApplicationDbContext where you can set that up just like your example.

Please let me know if this answered your question.

yaasierp commented 2 months ago

Hi Andre

Thanks for you previous reply. I have a problem mapping this json structure in IA.

{ "Type": "create", "Dummy1Information": { "Country": "SouthAfrica", "Did": "889", "InternalDummy2IdLocal":"525", "LoginId": "505462010", "TestDummy1Flag": true, "Brand": "Yeah", "Dummy1ModelCode": "1524", "Dummy1Color": "Silver", "Number": "123456", "Dummy2InformationAssociatedWithVIN": { "Dummy2Type": "Administrator", "AvailableServices": { "CanCreate": true, "CanView": true, "CanUpdate": true, "CanDelete": true }, "Dummy1Name": "data", "Dummy1Image": "data", "Dummy1ImageFilesExtension": "png", "Dummy1IconImage": "data", "Dummy1IconImageFilesExtension": "png", "Dummy2AgreementFlag": true } } }

This structure has nested objects and i can not change the structure. This will be an input parameter on a command e.g GetCommand(TestDto test). The problem i have is mapping/creating the entities/VO) for this because i can only map one level down and not add the other nested object to the DTO in the service to get this result or output.

I am using value objects because my understanding is that the DTO in service uses VO and not the Entities/Classes.

Can you please advise on what the best way is to map this out or how can this be done in IA.

You help will be greatly appreciated.

Regards Yaasier

dandrejvv commented 2 months ago

Hi @yaasierp Are you using the CQRS paradigm in describing your services? Also what would your Domain Entities look like from a domain designer point of view? You mentioned VOs (I presume Value Objects), is that what you are using to store the nested information in your Class Entity?

I'll preempt some of the explanation by giving a simple example that may partially (if not completely) answer your questions.

I've tried to recreate your JSON structure as both a Service endpoint as well as in the Domain. I managed to get the following:

From a Services side image

From a Domain side image

Inspecting the Create Entity Mapping on the CreateRootEntityCommand image

It generated the following code image

There is a slight issue in the Create Entity Mapping screen when it comes to creating fields on the DTO from the Domain onto nested DTOs but I overcome that by setting up those DTOs before I entered the mapping screen. Then on the mapping screen it was a simple exercise of connecting the dots.

We'll log a ticket to look into how to make it easier to work with but if you have any questions or need any point to be clarified, please let me know.

yaasierp commented 2 months ago

Hi Andre,

Thanks for the help previously,

Are you using the CQRS paradigm in describing your services? Yes I do. You mentioned VOs (I presume Value Objects), is that what you are using to store the nested information in your Class Entity? Yes its value objects. I have to use domain entities/classes and link the value objects to it based on the screenshots you sent and it worked. Thanks for that.

One more question if i may. IA generates a Validator for each entity i.e PersonValidator and the rules are in there. My question is how can i disable the auto validation for this on the api. I want to catch the exception the validator spits out i.e

{ "type": "https://httpstatuses.io/400", "title": "One or more validation errors occurred.", "status": 400, "errors": { "VehicleInformation.CountryId": [ "The length of 'Country Id' must be 3 characters or fewer. You entered 6 characters." ] }, "traceId": "00-7aa8ed7d9824ab09abf0f15d1c961c32-c29db2779a00f579-01" }

and then display a different message like this.

if(Validator.HasErrors) // I want to be able to control this/ modify it based on a condition. { return new TestResponse{Result="400", "Invalid Parameter"}; }

Regards Yaasier

joelsteventurner commented 2 months ago

Hi @yaasierp

There are a few ways one could do this, here are two options which might work for you:

Option 1 - Change the type of exception being throw. You could modify the ValidationBehaviour class, and change the type of exception which gets thrown

                if (failures.Count != 0)
                    throw new ValidationException(failures);

Option 2 - Re-map the fluent validation exception to an exception you would prefer.

You could change ASP.Net Core ExceptionFilter to remap the ValidationException to the kind of exception you would like.

    public class ExceptionFilter : Microsoft.AspNetCore.Mvc.Filters.IExceptionFilter
    {
        public void OnException(ExceptionContext context)
        {
            switch (context.Exception)
            {
                case ValidationException exception:
                    // Your custom logic here
                    break;
yaasierp commented 2 months ago

Hi Steven

Thanks for the info. But it didn't help much. I am still getting the ProblemDetails as a response and can only add fields to it. Is there a way to remove the ProblemDetails and have a custom error response which will only include the fields highlighted in the image.

image

{ "type": "https://httpstatuses.io/400", "title": "One or more validation errors occurred.", "status": 400, "errors": { "command": [ "The command field is required." ], "$.forgotToOperate": [ "'i' is an invalid start of a value. Path: $.forgotToOperate | LineNumber: 8 | BytePositionInLine: 27." ] }, "traceId": "00-e239fcd9c2ff520754d6a769ebf0af60-83410b454c8aed8f-01", "ReturnCode": "111100", "Message": "Invalid Parameter" }

The response should only have this when an error occurs.

image

{ "ReturnCode": "111100", "Message": "Invalid Parameter" }

Not sure if you can see the images so i have added the text as well.

Regards Yaasier

joelsteventurner commented 2 months ago

HI @yaasierp

Let me investigate and I'll get back to you today with a solution.

joelsteventurner commented 2 months ago

As per our Teams conversation, you should be all sorted to customize the ASP.Net core exception responses, to customize the architecture.

Let me know if you need any additional support here.