-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propuesta de Microservicio CQRS-ES DDD #1
base: main
Are you sure you want to change the base?
Conversation
The most important changes are the additions to the `.gitignore` file and the `PruebaTecnicaNet.sln` file. The `.gitignore` file now includes patterns for files and directories that should be ignored by Git, which helps to keep the repository clean and focused on the source code. The `PruebaTecnicaNet.sln` file has been updated with the basic structure of a Visual Studio solution file, which is used to manage and load projects. Changes: 1. The `.gitignore` file has been updated to include patterns for various files and directories that should be ignored by Git. This includes temporary files, build results, user-specific files, and files generated by popular Visual Studio add-ons. This change helps to prevent unnecessary files from being tracked and included in the repository, keeping it clean and focused on the source code. 2. The `PruebaTecnicaNet.sln` file has been updated with the basic structure of a Visual Studio solution file. This file is used by Visual Studio to manage and load projects. The added lines specify the format version, Visual Studio version, minimum Visual Studio version, and some global settings.
The most significant changes include the addition of a new project to the solution, the creation of a new class within this project, and the creation of a project file that specifies the project's settings. 1. A new project named "PruebaTecnicaNet.Domain" has been added to the solution "PruebaTecnicaNet.sln". This is a significant change as it expands the solution with a new project. The addition of this project is reflected in the solution file. (Reference: PruebaTecnicaNet.sln) 2. The project configurations for Debug and Release modes for the new project have been added. This includes the settings for the "Any CPU" platform. These configurations are crucial for the build and execution of the project in different modes and platforms. (Reference: PruebaTecnicaNet.sln) 3. A new class named "Class1" has been added to the "PruebaTecnicaNet.Domain" namespace. This class is a new component of the project and its addition is indicated in the "Class1.cs" file. (Reference: Class1.cs) 4. A new project file "PruebaTecnicaNet.Domain.csproj" has been created for the "PruebaTecnicaNet.Domain" project. This file is important as it specifies the project's settings, including the use of the "Microsoft.NET.Sdk", targeting the .NET 8.0 framework, and enabling implicit usings and nullable reference types. (Reference: PruebaTecnicaNet.Domain.csproj)
The most significant changes involve the creation of a new namespace `PruebaTecnicaNet.Domain.SettlementBankAggregate` and the addition of several classes and interfaces within this namespace. The `SettlementBank` class is particularly noteworthy as it implements multiple interfaces and includes several methods for validating its properties. 1. A new namespace `PruebaTecnicaNet.Domain.SettlementBankAggregate` has been created. This namespace will contain all the classes and interfaces related to the Settlement Bank Aggregate. 2. A new class `Entity` has been added to the `PruebaTecnicaNet.Domain.SettlementBankAggregate` namespace. This class will serve as a base class for other classes in the namespace. 3. Two new internal interfaces, `IAggregateRoot` and `ISettlementBankRepository`, have been added to the `PruebaTecnicaNet.Domain.SettlementBankAggregate` namespace. These interfaces will define the contract for the aggregate root and the repository of the Settlement Bank. 4. A new class `SettlementBank` has been added to the `PruebaTecnicaNet.Domain.SettlementBankAggregate` namespace. This class implements the `Entity`, `IAggregateRoot`, and `ISettlementBankRepository` interfaces. It also contains three private set properties: `Bic`, `Country`, and `Name`. 5. A constructor has been added to the `SettlementBank` class that takes three parameters: `bic`, `country`, and `name`. The constructor sets the properties and throws an exception if the `IsValid` method returns false. 6. Four methods have been added to the `SettlementBank` class: `IsBicValid`, `IsCountryValid`, `IsNameValid`, and `IsValid`. These methods check the validity of the `Bic`, `Country`, and `Name` properties.
The most significant changes involve the addition of validation checks in the `SettlementBank` class and the introduction of specific exception classes for invalid parameters and settlement banks. The `SettlementBank.cs` file has been updated to include new namespaces and the `IsValid` method now throws a specific `InvalidSettlementBankException`. The validation methods have been updated for more concise code. A new file `SettlementBankException.cs` has been added, defining a base exception class and several derived exception classes. The `Entity.cs` file has been added under a new namespace. 1. The `Class1.cs` and `Entity.cs` files under the `PruebaTecnicaNet.Domain.SettlementBankAggregate` namespace have been removed. 2. The `SettlementBank.cs` file now includes the `PruebaTecnicaNet.Domain.Exceptions`, `PruebaTecnicaNet.Domain.SeedWork`, and `PruebaTecnicaNet.Domain.Exceptions.SettlementBankException` namespaces. 3. The constructor in the `SettlementBank` class has been updated to include validation checks for `bic`, `country`, and `name` parameters, throwing appropriate exceptions if they are null, empty, or fail validation. 4. The `IsValid` method in the `SettlementBank` class now throws an `InvalidSettlementBankException` instead of a generic `Exception`. 5. The validation methods `IsBicValid`, `IsCountryValid`, and `IsNameValid` in the `SettlementBank` class now use expression-bodied members. 6. A new file `SettlementBankException.cs` has been added under the `PruebaTecnicaNet.Domain.Exceptions` namespace, defining a base `SettlementBankException` class and several derived exception classes. 7. The `Entity.cs` file has been added under the `PruebaTecnicaNet.Domain.SeedWork` namespace, defining an `Entity` class with no members.
The most significant changes were made to the `SettlementBankException.cs`, `Entity.cs`, and `SettlementBank.cs` files. The `SettlementBankException.cs` file was updated to include a namespace and several exception classes for handling different types of exceptions in the `SettlementBank` class. The `Entity.cs` file was updated with new properties and methods to handle domain events and provide more robust equality checks. The `SettlementBank.cs` file was updated with new properties and methods to validate and update its properties. Here is a list of the changes: 1. `SettlementBankException.cs` was updated to include a namespace and several exception classes for different types of exceptions in the `SettlementBank` class. These exceptions include `InvalidBicException`, `InvalidCountryException`, `InvalidNameException`, and `InvalidSettlementBankException`. 2. `PruebaTecnicaNet.Domain.csproj` was updated to include references to the `MediatR` and `System.Reflection.TypeExtensions` packages. 3. `Entity.cs` was updated to include several new properties and methods for handling domain events and providing more robust equality checks. 4. `IAggregateRoot.cs` was removed and then added back with no changes. 5. `ISettlementBankRepository.cs` was updated to include a namespace. 6. `SettlementBank.cs` was updated to include several new properties and methods for validating and updating its properties. 7. `GlobalUsings.cs` was added with global using directives for `MediatR`, `PruebaTecnicaNet.Domain.Exceptions`, `PruebaTecnicaNet.Domain.SeedWork`, and `PruebaTecnicaNet.Domain.Events`. 8. `SettlementBankBicUpdatedEvent.cs`, `SettlementBankCountryUpdatedEvent.cs`, and `SettlementBankNameUpdatedEvent.cs` files were added. These files define events that are raised when the `Bic`, `Country`, and `Name` properties of a `SettlementBank` are updated. 9. `IAggregateRoot.cs` was updated to include a namespace and a summary comment.
…`Entity` class in `Entity.cs` and the `SettlementBank` class in `SettlementBank.cs`. These comments provide a brief summary of what each method does and what it returns, enhancing the readability and understanding of the code. Changes: 1. The `Entity` class in `Entity.cs` has been updated with additional comments for several methods. These comments provide a brief summary of what each method does and what it returns. The methods with added comments include `IsTransient()`, `Equals(object obj)`, `GetHashCode()`, `operator ==(Entity left, Entity right)`, and `operator !=(Entity left, Entity right)`. 2. The `SettlementBank` class in `SettlementBank.cs` has been updated with a comment that describes it as a settlement bank entity. References to the code changes: 1. `Entity.cs`: Added comments to `IsTransient()`, `Equals(object obj)`, `GetHashCode()`, `operator ==(Entity left, Entity right)`, and `operator !=(Entity left, Entity right)`. 2. `SettlementBank.cs`: Added a comment describing the `SettlementBank` class.
The most significant changes include the modification of the `Entity` class to allow nullable types for the `_domainEvents` list and its corresponding public property `DomainEvents`. This change enhances flexibility in scenarios where no domain events have been added to the entity. The `Equals` method in the `Entity` class has also been updated for better readability. The `IAggregateRoot` and `ISettlementBankRepository` interfaces have been changed from `internal` to `public`, expanding their usability. The `SettlementBank` class has been updated to implement the `ISettlementBankRepository` interface and its methods, indicating future implementation. Here is a list of the changes: 1. The `Entity` class in `Entity.cs` has been modified to allow nullable types for the `_domainEvents` list and its corresponding public property `DomainEvents`. This change allows the list to be null, which can be useful in scenarios where no domain events have been added to the entity. 2. The `Equals` method in the `Entity` class has been updated to use the `is not` pattern for checking if the passed object is not of type `Entity`. This is a more modern and readable way to perform the check compared to the previous method. 3. The `IAggregateRoot` and `ISettlementBankRepository` interfaces have been changed from `internal` to `public`, allowing them to be used outside of their defining assembly. 4. The `ISettlementBankRepository` interface has been extended with a number of new methods for adding, updating, and finding `SettlementBank` entities, as well as checking their existence. 5. The `SettlementBank` class has been updated to implement the `ISettlementBankRepository` interface and its methods. Currently, all of these methods throw a `NotImplementedException`, indicating that they will be implemented in the future. 6. Two new interfaces, `IRepository<T>` and `IUnitOfWork`, have been added to the `PruebaTecnicaNet.Domain.SeedWork` namespace. These interfaces define common operations for repositories and units of work, respectively.
…ameter type in several methods within `ISettlementBankRepository.cs` and `SettlementBank.cs`, and the addition of a new `Code` property in the `SettlementBank` class. The `id` parameter type has been changed from `Guid` to `int` in the `FindByIdAsync`, `ExistsAsync`, and `ExistsByCodeAsync` methods, suggesting a shift in the unique identifier for a `SettlementBank`. The new `Code` property in the `SettlementBank` class indicates that a `SettlementBank` now has a code that can be set and retrieved. In `Entity.cs`, the nullable type for the `_domainEvents` list and its getter `DomainEvents` has been removed, ensuring that `_domainEvents` will always be initialized and `DomainEvents` will always return a non-null value. List of changes: 1. In `Entity.cs`, the nullable type for the `_domainEvents` list and its getter `DomainEvents` has been removed, ensuring that `_domainEvents` will always be initialized and `DomainEvents` will always return a non-null value. 2. In `ISettlementBankRepository.cs`, the type of the `id` parameter in the `FindByIdAsync` and `ExistsAsync` methods has been changed from `Guid` to `int`. The same change has been made for the `ExistsByCodeAsync` methods. 3. In `SettlementBank.cs`, a new property `Code` has been added to the `SettlementBank` class. 4. In `SettlementBank.cs`, the `FindByIdAsync`, `ExistsAsync`, and `ExistsByCodeAsync` methods have been updated to reflect the change in the `id` parameter type from `Guid` to `int`.
…cs` file to include global usings for various namespaces, the update of the `PruebaTecnicaNet.Infraestructure.csproj` file to target the .NET 8.0 framework and the inclusion of a new project `PruebaTecnicaNet.Infraestructure` in the `PruebaTecnicaNet.sln` solution file. 1. The `GlobalUsings.cs` file has been updated to include global usings for various namespaces. This means that these namespaces are now globally available across the entire project and do not need to be individually imported in each file. 2. The `PruebaTecnicaNet.Infraestructure.csproj` file has been updated to target the .NET 8.0 framework. It also enables implicit usings and nullable reference types. A project reference to `PruebaTecnicaNet.Domain.csproj` has been added, indicating a dependency on this project. A package reference to `Npgsql.EntityFrameworkCore.PostgreSQL` version `8.0.2` has been added, indicating that this package is required by the project. A new folder named `Migrations` has also been included in the project. 3. The `PruebaTecnicaNet.sln` solution file has been updated to include a new project `PruebaTecnicaNet.Infraestructure`. This project has been added as a dependency to the `PruebaTecnicaNet.Domain` project. The solution configurations for the `PruebaTecnicaNet.Infraestructure` project have been set for both Debug and Release modes for the Any CPU platform.
…tlementBankContext` in the `PruebaTecnicaNet.Infraestructure` namespace. This class extends the `DbContext` class and implements the `IUnitOfWork` interface. It contains a `DbSet` property `SettlementBanks` of type `SettlementBank` and two private fields: `_mediator` and `_currentTransaction`. The class also includes two constructors, several methods for transaction management, and the enabling of nullable reference types. Here are the changes in detail: 1. A new class `SettlementBankContext` has been added to the `PruebaTecnicaNet.Infraestructure` namespace. This class extends the `DbContext` class and implements the `IUnitOfWork` interface. 2. The `SettlementBankContext` class has a `DbSet` property `SettlementBanks` of type `SettlementBank`. 3. The class has two private fields: `_mediator` of type `IMediator` and `_currentTransaction` of type `IDbContextTransaction`. 4. Two constructors have been added to the class. The first constructor takes `DbContextOptions<SettlementBankContext>` as a parameter. The second constructor takes `DbContextOptions<SettlementBankContext>` and `IMediator` as parameters. If the `IMediator` parameter is null, an `ArgumentNullException` is thrown. 5. The class has a method `GetCurrentTransaction` that returns the current transaction. 6. The class has a property `HasActiveTransaction` that checks if a current transaction exists. 7. The `OnModelCreating` method has been overridden to set the default schema to "bank" and apply configurations from the assembly of `SettlementBankContext`. 8. The class has a method `SaveEntitiesAsync` that dispatches domain events and saves changes to the database. 9. The class has a method `BeginTransactionAsync` that begins a new transaction if there isn't a current transaction. 10. The class has a method `CommitTransactionAsync` that commits the current transaction and saves changes to the database. If the transaction parameter is null or not the current transaction, an exception is thrown. 11. The class has a method `RollbackTransaction` that rolls back the current transaction. 12. Nullable reference types have been enabled for the class with `#nullable enable`.
…tlementBankTypeConfiguration` in the `PruebaTecnicaNet.Infraestructure.EntityConfigurations` namespace, which implements the `IEntityTypeConfiguration<SettlementBank>` interface and defines the configuration for the `SettlementBank` entity. Another major change is the creation of a new static class `MediatorExtension` in the `PruebaTecnicaNet.Infraestructure` namespace, which contains an extension method `DispatchDomainEventsAsync` for the `IMediator` interface. List of Changes: 1. A new class `SettlementBankTypeConfiguration` has been added in the `PruebaTecnicaNet.Infraestructure.EntityConfigurations` namespace. This class implements the `IEntityTypeConfiguration<SettlementBank>` interface and defines the configuration for the `SettlementBank` entity. The configuration includes table name, ignored properties, property configurations, and indexes. 2. A new static class `MediatorExtension` has been added in the `PruebaTecnicaNet.Infraestructure` namespace. This class contains an extension method `DispatchDomainEventsAsync` for the `IMediator` interface. The method asynchronously dispatches domain events that are tracked by the `SettlementBankContext` change tracker. The method first retrieves the domain entities that have domain events, then it retrieves the domain events from these entities, clears the domain events from the entities, and finally publishes each domain event using the mediator.
…lass, as well as the addition of four properties to the new class. 1. A new file named `ClientRequest.cs` has been created in the `PruebaTecnicaNet.Infraestructure.Idempotency` namespace. This file contains the definition of a new class named `ClientRequest`. 2. The `ClientRequest` class has been defined with four properties. These include: * `Id` of type `Guid`. * `Name` of type `string`. This property is required as indicated by the `[Required]` attribute. * `Request` of type `string`. * `Time` of type `DateTime`. References to the code changes: 1. Creation of `ClientRequest.cs` file: `PruebaTecnicaNet.Infraestructure.Idempotency/ClientRequest.cs` 2. Definition of `ClientRequest` class and its properties: `PruebaTecnicaNet.Infraestructure.Idempotency/ClientRequest.cs`
…`IRequestManager` and its implementation `RequestManager` in the `PruebaTecnicaNet.Infraestructure.Idempotency` namespace. The `IRequestManager` interface defines two methods, `ExistAsync` and `CreateRequestForCommandAsync`, which are implemented in the `RequestManager` class. The `RequestManager` class also includes a private field `_context` of type `SettlementBankContext` and a constructor that initializes this field. List of changes: 1. A new interface `IRequestManager` was created in the `PruebaTecnicaNet.Infraestructure.Idempotency` namespace. This interface defines two methods: `ExistAsync` and `CreateRequestForCommandAsync`. The `ExistAsync` method takes a `Guid` as an argument and returns a `Task<bool>`, while the `CreateRequestForCommandAsync` method takes a `Guid` and a generic type `T` as arguments and returns a `Task`. 2. The `RequestManager` class was created in the same namespace as the `IRequestManager` interface. This class implements the `IRequestManager` interface. It has a private field `_context` of type `SettlementBankContext` and a constructor that initializes this field. 3. The `CreateRequestForCommandAsync` method in the `RequestManager` class checks if a request with the given `id` already exists by calling the `ExistAsync` method. If it does, it throws a `SettlementBankException`. Otherwise, it creates a new `ClientRequest` with the `id`, the name of the type `T`, and the current UTC time, adds it to the `_context`, and saves the changes. 4. The `ExistAsync` method in the `RequestManager` class finds a `ClientRequest` with the given `id` in the `_context` and returns `true` if it exists and `false` otherwise. References to the code changes can be found in the `PruebaTecnicaNet.Infraestructure.Idempotency` namespace.
…`PruebaTecnicaNet.Infraestructure.Repositories` and a new class `SettlementBankRepository` within it. This class implements the `ISettlementBankRepository` interface and includes a private readonly field `_context` of type `SettlementBankContext`. A public property `UnitOfWork` has also been added which returns `_context`. The `SettlementBankRepository` class now includes a variety of methods for adding, checking the existence of, finding, and updating `SettlementBank` entities in the context. These methods support different parameters, including id, code, name, and a nullable id. Some methods also support cancellation tokens. Here is the list of changes: 1. A new namespace `PruebaTecnicaNet.Infraestructure.Repositories` has been added. 2. A new class `SettlementBankRepository` has been created which implements the `ISettlementBankRepository` interface. 3. A private readonly field `_context` of type `SettlementBankContext` has been added to the `SettlementBankRepository` class. 4. A public property `UnitOfWork` has been added to the `SettlementBankRepository` class which returns `_context`. 5. The `SettlementBankRepository` class now includes the following methods: - `Add(SettlementBank settlementBank)`: Adds a new `SettlementBank` to the context and returns the entity. - `ExistsAsync(int id)`: Checks if a `SettlementBank` with the given id exists in the context. - `ExistsByCodeAsync(string code)`: Checks if a `SettlementBank` with the given code exists in the context. - `ExistsByCodeAsync(string code, int id)`: Checks if a `SettlementBank` with the given code and id exists in the context. - `ExistsByCodeAsync(string code, int? id)`: Checks if a `SettlementBank` with the given code and nullable id exists in the context. - `ExistsByCodeAsync(string code, int id, CancellationToken cancellationToken)`: Checks if a `SettlementBank` with the given code and id exists in the context, with cancellation token support. - `ExistsByCodeAsync(string code, int? id, CancellationToken cancellationToken)`: Checks if a `SettlementBank` with the given code and nullable id exists in the context, with cancellation token support. - `ExistsByCodeAsync(string code, CancellationToken cancellationToken)`: Checks if a `SettlementBank` with the given code exists in the context, with cancellation token support. - `ExistsByNameAsync(string name)`: Checks if a `SettlementBank` with the given name exists in the context. - `FindAllAsync()`: Returns a list of all `SettlementBank` entities in the context. - `FindByIdAsync(int id)`: Finds and returns a `SettlementBank` with the given id from the context. - `FindByNameAsync(string name)`: Finds and returns a `SettlementBank` with the given name from the context. - `Update(SettlementBank settlementBank)`: Updates a `SettlementBank` in the context.
…oj` file to target the .NET 8.0 framework, the addition of two package references, and the creation of a new project named `EventBus`. The `EventBus` project has also been added to the `PruebaTecnicaNet.sln` solution file, and build configurations for this project have been set up. 1. The `EventBus.csproj` file has been updated to target the .NET 8.0 framework. This change also includes the enabling of implicit usings and nullable reference types. Additionally, two package references, `Microsoft.Extensions.DependencyInjection.Abstractions` and `Microsoft.Extensions.Options`, have been added with versions 8.0.0 and 8.0.2 respectively. 2. A new project named `EventBus` has been created and added to the `PruebaTecnicaNet.sln` solution file. This is indicated by the new project reference to `EventBus` in the solution file. 3. The global section of the `PruebaTecnicaNet.sln` file has been updated to include build and active configurations for the `EventBus` project for both Debug and Release modes. This means that the `EventBus` project will be built and can be debugged or released as part of the solution.
…and record in the `IntegrationEvent.cs` file, and the inclusion of two new global using directives in the `GlobalUsings.cs` file. 1. A new namespace `EventBus.Events` has been added in the `IntegrationEvent.cs` file. Within this namespace, a new record `IntegrationEvent` has been created. This record includes a constructor that initializes `Id` with a new `Guid` and `CreationDate` with the current UTC date and time. It also includes two properties `Id` and `CreationDate` that are decorated with the `JsonInclude` attribute, indicating that these properties should be included when the record is serialized to JSON. 2. In the `GlobalUsings.cs` file, two new global using directives have been added. The first one is `System.Text.Json.Serialization`, which provides attributes that can be used to control how objects are serialized to JSON. The second one is `EventBus.Events`, which is the namespace of the `IntegrationEvent` record. This allows the `IntegrationEvent` record to be used in other files without needing to explicitly import its namespace. References to the code changes: - `IntegrationEvent.cs` file: Addition of new namespace `EventBus.Events` and record `IntegrationEvent`. - `GlobalUsings.cs` file: Addition of new global using directives `System.Text.Json.Serialization` and `EventBus.Events`.
…s that define interfaces and classes for an event bus system. These include `EventBusSubscriptionInfo.cs`, `IEventBus.cs`, `IEventBusBuilder.cs`, and `IIntegrationEventHandler.cs`. 1. `EventBusSubscriptionInfo.cs`: This new file contains the `EventBusSubscriptionInfo` class, which includes a dictionary of event types and a `JsonSerializerOptions` object. It also provides a static `JsonSerializerOptions` object and a method for creating a default type resolver. 2. `IEventBus.cs`: This file introduces the `IEventBus` interface, which includes a `PublishAsync` method that accepts an `IntegrationEvent` object as a parameter. 3. `IEventBusBuilder.cs`: This file defines the `IEventBusBuilder` interface, which includes a `Services` property of type `IServiceCollection`. 4. `IIntegrationEventHandler.cs`: This file includes two interfaces: `IIntegrationEventHandler<TIntegrationEvent>` and `IIntegrationEventHandler`. The `IIntegrationEventHandler<TIntegrationEvent>` interface includes a `Handle` method that accepts a `TIntegrationEvent` object as a parameter and an explicit implementation of the `Handle` method from the `IIntegrationEventHandler` interface. The `IIntegrationEventHandler` interface includes a `Handle` method that accepts an `IntegrationEvent` object as a parameter.
…EventBusBuilderExtensions.cs` and `GenericTypeExtensions.cs`, which provide extension methods for the `IEventBusBuilder` interface, `Type` class, and `object` class. In `EventBusBuilderExtensions.cs`, two methods have been added. The `ConfigureJsonOptions` method allows for the configuration of JSON serialization options for the event bus. The `AddSubscription` method enables the addition of a subscription to the event bus for a specific event type and handler, and also keeps track of all registered event types and their name mapping. In `GenericTypeExtensions.cs`, two methods have been added for the `Type` class and `object` class. The `GetGenericTypeName` methods return the name of the generic type. If the type is not generic, it simply returns the type name. If the type is generic, it constructs a string with the type name and its generic arguments. Changes: 1. Added `EventBusBuilderExtensions.cs` file with `ConfigureJsonOptions` and `AddSubscription` methods for the `IEventBusBuilder` interface. 2. Added `GenericTypeExtensions.cs` file with `GetGenericTypeName` methods for the `Type` class and `object` class.
… the solution, the configuration of this project for both Debug and Release configurations, the creation of a new class within the project's namespace, and the creation of the project file with .NET 8.0 as the target framework. Changes: 1. A new project named "IntegrationEventLogEF" has been added to the solution "PruebaTecnicaNet.sln". This is a significant addition as it expands the solution with a new project. The change is reflected in the solution file where a new project line has been added. 2. The "IntegrationEventLogEF" project has been configured for both Debug and Release configurations for the "Any CPU" platform. This ensures that the project can be built and run in both Debug and Release modes on any CPU architecture. The change is evident from the addition of configuration lines in the solution file. 3. A new class named "Class1" has been added to the "IntegrationEventLogEF" namespace. This class is a new component of the project and its addition signifies the expansion of the project's functionality. The change is shown by the addition of the class definition in the "Class1.cs" file. 4. The project file for "IntegrationEventLogEF" has been created with .NET 8.0 as the target framework. This sets the foundation for the project's development and determines the versions of .NET APIs that can be used in the project. The project file also enables implicit usings and nullable reference types, which are features that can enhance code readability and safety. The change is shown by the addition of the project file "IntegrationEventLogEF.csproj".
The most significant changes in the codebase involve the addition of various namespaces across multiple files, the addition of new methods to interfaces, and modifications to project properties. 1. Several namespaces were added across multiple files, including `System`, `System.Collections.Generic`, `System.Threading.Tasks`, and `System.Linq`. These namespaces provide access to fundamental classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions. They also provide classes that support threading and parallel programming, and classes that define extension methods that add functionality to existing types. 2. New methods were added to the `IEventBus` and `IIntegrationEventHandler` interfaces. The `PublishAsync` method was added to the `IEventBus` interface, and the `Handle` method was added to the `IIntegrationEventHandler` interface. These methods likely provide new functionality for event handling and publishing. 3. Project properties were modified in several `.csproj` files. The `ImplicitUsings` and `Nullable` properties were removed, and new properties like `RootNamespace`, `IsAotCompatible`, and `IsPublishable` were added. These changes likely affect the build and runtime behavior of the projects. 4. A package reference to `Npgsql.EntityFrameworkCore.PostgreSQL` and a project reference to `EventBus.csproj` were added to `IntegrationEventLogEF.csproj`. This suggests that the project now uses the Npgsql provider for Entity Framework Core, which allows the use of PostgreSQL as the database, and also depends on the `EventBus` project. 5. The `System.Threading` namespace was added to several files, indicating that multithreading functionality may have been introduced in these parts of the codebase. References to the code changes can be found in the original list of changes.
…ile from the `IntegrationEventLogEF` namespace, the addition of a new project `SettlementBank.UnitTests` to the `PruebaTecnicaNet.sln` solution file, and the addition of several new files to the `IntegrationEventLogEF` namespace and its sub-namespaces. These new files include `EventStateEnum.cs`, `IntegrationEventLogEntry.cs`, `IntegrationLogExtensions.cs`, `IIntegrationEventLogService.cs`, `IntegrationEventLogService.cs`, and `ResilientTransaction.cs`. Additionally, the `SettlementBank.cs` file was updated to change the order of setting certain properties, and the `Global` section of the `PruebaTecnicaNet.sln` solution file was updated to include build configurations for the new `SettlementBank.UnitTests` project. Here is a list of the changes: 1. The `Class1.cs` file was removed from the `IntegrationEventLogEF` namespace. 2. The order of setting the `Bic`, `Country`, and `Name` properties was changed in `SettlementBank.cs`. 3. A new project `SettlementBank.UnitTests` was added to the `PruebaTecnicaNet.sln` solution file. 4. The `Global` section of the `PruebaTecnicaNet.sln` solution file was updated to include build configurations for the new `SettlementBank.UnitTests` project. 5. A new `EventStateEnum.cs` file was added to the `IntegrationEventLogEF` namespace. 6. Several global using directives were added to `GlobalUsings.cs`. 7. A new `IntegrationEventLogEntry.cs` file was added to the `IntegrationEventLogEF` namespace. 8. A new `IntegrationLogExtensions.cs` file was added to the `IntegrationEventLogEF` namespace. 9. A new `IIntegrationEventLogService.cs` file was added to the `IntegrationEventLogEF.Services` namespace. 10. A new `IntegrationEventLogService.cs` file was added to the `IntegrationEventLogEF.Services` namespace. 11. A new `ResilientTransaction.cs` file was added to the `IntegrationEventLogEF.Utilities` namespace. 12. A new `SettlementBank.UnitTests.csproj` project file was added. 13. A new `SettlementBankAggregateTest.cs` file was added to the `SettlementBank.UnitTests.Domain` namespace.
…nal operator from the `EventTypeShortName` property in `IntegrationEventLogEntry.cs`, indicating that `EventTypeName` is now expected to always be non-null. The `_context` field in `SettlementBankRepository.cs` was initialized to `default!`, likely to meet a non-nullability requirement. The test methods in `SettlementBankAggregateTest.cs` were refactored to combine the "Act" and "Assert" phases. A new file `Builders.cs` was added, containing a `SettlementBankBuilder` class for creating `SettlementBank` instances with specific properties. Lastly, a new file `GlobalSuppressions.cs` was added to suppress specific code analysis warnings. List of changes: 1. In `IntegrationEventLogEntry.cs`, the null-conditional operator `?.` was removed from the `EventTypeShortName` property, indicating that `EventTypeName` is expected to always be non-null. 2. In `SettlementBankRepository.cs`, the `_context` field was initialized to `default!`, likely to meet a non-nullability requirement. 3. In `SettlementBankAggregateTest.cs`, several `using` directives were removed and the test methods were refactored to combine the "Act" and "Assert" phases. 4. In `GlobalUsings.cs`, several global `using` directives were removed and one was added for `Xunit`, indicating a change in the libraries used across the project. 5. A new file `Builders.cs` was added, containing a `SettlementBankBuilder` class for creating `SettlementBank` instances with specific properties. 6. A new file `GlobalSuppressions.cs` was added, containing several `SuppressMessage` attributes to suppress specific code analysis warnings.
…ionEventLogEF` project into the `PruebaTecnicaNet.Infraestructure` project and the `SettlementBankContext` class. The `PruebaTecnicaNet.Infraestructure.csproj` file now includes a reference to the `IntegrationEventLogEF.csproj` project, allowing it to utilize its classes and methods. Additionally, the `SettlementBankContext` class has been updated to use the `IntegrationEventLogEF` namespace and to use integration event logs when creating its models. Changes: 1. The `PruebaTecnicaNet.Infraestructure.csproj` file has been updated to include a reference to the `IntegrationEventLogEF.csproj` project. This allows the `PruebaTecnicaNet.Infraestructure` project to use the classes and methods of the `IntegrationEventLogEF` project. (Reference: `PruebaTecnicaNet.Infraestructure.csproj`) 2. The `IntegrationEventLogEF` namespace has been added to the `SettlementBankContext.cs` file. This allows the `SettlementBankContext` class to use the classes and methods from the `IntegrationEventLogEF` namespace without having to fully qualify their names. (Reference: `SettlementBankContext.cs`) 3. The `OnModelCreating` method in the `SettlementBankContext` class has been updated. The comment `// TODO: logs here` has been replaced with a call to `modelBuilder.UseIntegrationEventLogs()`, indicating that the `SettlementBankContext` will now use integration event logs when creating its models. (Reference: `SettlementBankContext.cs`)
The most significant changes involve the renaming of namespaces across multiple files and projects. The namespaces have been changed from their original names to include a new prefix `PruebaTecnicaNet`. This change affects files in the `EventBus`, `IntegrationEventLogEF`, and `SettlementBank.UnitTests.Domain` namespaces. 1. The namespace of several files in the `EventBus.Abstractions` namespace has been changed to `PruebaTecnicaNet.EventBus.Abstractions`. This affects the files `EventBusSubscriptionInfo.cs`, `IEventBus.cs`, and `IIntegrationEventHandler.cs`. 2. The root namespace in the `EventBus.csproj` project file has been changed to `PruebaTecnicaNet.EventBus`. 3. The namespace of the `IntegrationEvent.cs` file has been changed to `PruebaTecnicaNet.EventBus.Events`. 4. The namespaces in the `EventBusBuilderExtensions.cs` file have been changed to `PruebaTecnicaNet.EventBus.Abstractions` and `PruebaTecnicaNet.EventBus.Extensions`. 5. The namespace of the `GenericTypeExtensions.cs` file has been changed to `PruebaTecnicaNet.EventBus.Extensions`. 6. The global using namespace in the `GlobalUsings.cs` file has been changed to `PruebaTecnicaNet.EventBus.Events`. 7. The namespace of the `EventStateEnum.cs` file has been changed to `PruebaTecnicaNet.IntegrationEventLogEF`. 8. The root namespace in the `IntegrationEventLogEF.csproj` project file has been changed to `PruebaTecnicaNet.IntegrationEventLogEF`. 9. The namespace of the `IntegrationEventLogEntry.cs` file has been changed to `PruebaTecnicaNet.IntegrationEventLogEF`. 10. The namespace of the `IntegrationLogExtensions.cs` file has been changed to `PruebaTecnicaNet.IntegrationEventLogEF`. 11. The namespace of the `IIntegrationEventLogService.cs` file has been changed to `PruebaTecnicaNet.IntegrationEventLogEF.Services`. 12. The namespace of the `IntegrationEventLogService.cs` file has been changed to `PruebaTecnicaNet.IntegrationEventLogEF.Services`. 13. The namespace of the `ResilientTransaction.cs` file has been changed to `PruebaTecnicaNet.IntegrationEventLogEF.Utilities`. 14. The namespace of the `SettlementBankContext.cs` file has been changed to `PruebaTecnicaNet.IntegrationEventLogEF`. 15. The namespace of the `Builders.cs` file has been changed to `PruebaTecnicaNet.SettlementBank.UnitTests.Domain`. 16. The namespace of the `SettlementBankAggregateTest.cs` file has been changed to `PruebaTecnicaNet.SettlementBank.UnitTests.Domain`.
…three classes in the `PruebaTecnicaNet.Domain.Events` namespace. The classes `SettlementBankBicUpdatedEvent`, `SettlementBankCountryUpdatedEvent`, and `SettlementBankNameUpdatedEvent` have been removed and replaced with `SettlementBankBicUpdatedDomainEvent`, `SettlementBankCountryUpdatedDomainEvent`, and `SettlementBankNameUpdatedDomainEvent` respectively. These changes have been reflected in the `SettlementBank` class. Additionally, the project GUIDs in the solution file `PruebaTecnicaNet.sln` have been updated, possibly due to a change in the version of Visual Studio used. Two new solution items, `.gitignore` and `README.md`, have been added to the solution. Changes: 1. Removal of `SettlementBankBicUpdatedEvent`, `SettlementBankCountryUpdatedEvent`, and `SettlementBankNameUpdatedEvent` classes from `PruebaTecnicaNet.Domain.Events` namespace. 2. Addition of `SettlementBankBicUpdatedDomainEvent`, `SettlementBankCountryUpdatedDomainEvent`, and `SettlementBankNameUpdatedDomainEvent` classes to `PruebaTecnicaNet.Domain.Events` namespace. 3. Replacement of instances of the removed classes with instances of the new classes in the `SettlementBank` class, specifically in the `UpdateBic`, `UpdateCountry`, and `UpdateName` methods. 4. Update of project GUIDs in the solution file `PruebaTecnicaNet.sln`. 5. Addition of `.gitignore` and `README.md` files to the solution.
…` classes. In the `Entity` class, the getter and setter for the `Id` property, the `AddDomainEvent` method, and the `IsTransient` method have been simplified. The `RemoveDomainEvent` and `ClearDomainEvents` methods have been swapped. A `GetHashCode` method was added and then removed. In the `SettlementBank` class, it no longer implements the `ISettlementBankRepository` interface and the `UnitOfWork` property and several repository methods have been removed. A `Required` data annotation has been added to the `Bic` property. The `SettlementBankAggregateTest` class now uses the `NSubstitute.ExceptionExtensions` namespace. List of changes: 1. The `Entity` class's `Id` property getter and setter have been simplified to use expression-bodied members. 2. The `AddDomainEvent` method in the `Entity` class now uses the null-coalescing assignment operator (`??=`) to simplify the initialization of the `_domainEvents` list. 3. The `RemoveDomainEvent` and `ClearDomainEvents` methods in the `Entity` class have been swapped. 4. The `IsTransient` method in the `Entity` class has been simplified to use an expression-bodied member. 5. A `GetHashCode` method was added to the `Entity` class, which calculates a hash code for the entity based on its `Id` property. This method was later removed. 6. The `SettlementBank` class no longer implements the `ISettlementBankRepository` interface and a `Required` data annotation has been added to the `Bic` property. 7. The `UnitOfWork` property and several repository methods (`Add`, `Update`, `GetAsync`) have been removed from the `SettlementBank` class. 8. The `SettlementBankAggregateTest` class now uses the `NSubstitute.ExceptionExtensions` namespace.
…` file to ignore several directories and files, the addition of new projects to the `PruebaTecnicaNet.sln` file, and the update to the global section of the `PruebaTecnicaNet.sln` file to include build configurations for the newly added projects. 1. The `.dockerignore` file has been updated to ignore a number of directories and files, which will prevent them from being included in the Docker build context. This can help to reduce the size of the Docker image and speed up the build process. However, certain files within the `.git` directory have been configured to not be ignored. This could be useful if the Dockerfile needs to access information about the Git repository, such as the latest commit hash. 2. Several new projects have been added to the `PruebaTecnicaNet.sln` file, including `PuebaTecnicaNet.API`, `PruebaTecnicaNet.ServiceDefaults`, and `EventBusRabbitMQ`. This could indicate that the application is being split into smaller, more manageable components, or that new functionality is being added. Additionally, the `SettlementBank.UnitTests` project and the `Elementos de la solución` project have been updated with new solution items, which could suggest that new tests have been written or existing tests have been updated. 3. The global section of the `PruebaTecnicaNet.sln` file has been updated to include build configurations for the newly added projects. These configurations specify that the projects should be built in both Debug and Release modes for the Any CPU platform. This could help to ensure that the projects are built correctly for all supported platforms, and that they can be easily switched between Debug and Release modes for testing and deployment purposes.
…n.cs`, `Entity.cs`, `ISettlementBankRepository.cs`, and `SettlementBank.cs` files. These changes include the addition of new constructors in `SettlementBankException.cs`, null-checking in `Entity.cs`, a parameter change in `ISettlementBankRepository.cs`, and several modifications in `SettlementBank.cs`. 1. In `SettlementBankException.cs`, new constructors were added to the `SettlementBankException` class. These constructors either have no parameters or include an additional `innerException` parameter. 2. In `Entity.cs`, null-checking was introduced to the `DomainEvents` property getter and the `AddDomainEvent` method. This was done to prevent a `NullReferenceException` from occurring if `_domainEvents` is null. 3. In `ISettlementBankRepository.cs`, the `GetAsync` method's parameter was changed from an integer `id` to a string `Bic`. 4. In `SettlementBank.cs`, the `IsBicValid` method was modified to allow a `bic` string length of up to 100 characters, instead of exactly 8. 5. Also in `SettlementBank.cs`, the variable name for the domain event was changed from `settlementBankBicUpdatedEvent` to `settlementBankBicUpdatedDomainEvent` and the `AddDomainEvent` method was called on `this` object. 6. In the `UpdateCountry` method of `SettlementBank.cs`, the variable name for the domain event was changed from `settlementBankUpdatedEvent` to `settlementBankUpdatedDomainEvent` and the `AddDomainEvent` method was called on `this` object. 7. In the `UpdateName` method of `SettlementBank.cs`, the variable name for the domain event was changed from `settlementBankUpdatedEvent` to `settlementBankUpdatedDomainEvent` and the `AddDomainEvent` method was called on `this` object.
…ager` and `SettlementBankRepository` classes in their respective files, which have been changed from `internal` to `public`, making them accessible from other assemblies. Additionally, the `GetAsync` method in `SettlementBankRepository.cs` now accepts a `string Bic` parameter instead of an `int id`. The default schema for the `modelBuilder` in `SettlementBankContext.cs` has also been changed. Here are the changes in detail: 1. The `RequestManager` class in `RequestManager.cs` has been changed from `internal` to `public`, making it accessible from other assemblies. (RequestManager.cs) 2. In `SettlementBankRepository.cs`, several changes have been made: - The `using` directives have been modified to include `System` and `System.Threading.Tasks`, while `System.Collections.Generic` and `System.Threading` have been removed. (SettlementBankRepository.cs) - The `SettlementBankRepository` class has been changed from `internal` to `public`, making it accessible from other assemblies. (SettlementBankRepository.cs) - The constructor of `SettlementBankRepository` has been modified to throw an `ArgumentNullException` if the `context` parameter is `null`. (SettlementBankRepository.cs) - The `GetAsync` method has been changed to accept a `string Bic` parameter instead of an `int id`. (SettlementBankRepository.cs) 3. In `SettlementBankContext.cs`, the default schema for the `modelBuilder` in the `OnModelCreating` method has been changed from `"bank"` to `"SettlementBankDB"`. (SettlementBankContext.cs)
…named `SettlementBankDB` with two new tables `banks` and `IntegrationEventLog`, and a sequence `bankseq`. The `banks` table has five columns, with `Id` as the primary key and unique indexes on the `Bic` column. The `IntegrationEventLog` table has seven columns, with `EventId` as the primary key. The `ProductVersion` is set to `8.0.2` and `Relational:MaxIdentifierLength` is set to `63`. The `NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder)` method is called, and the `NpgsqlPropertyBuilderExtensions.UseHiLo(b.Property<int>("Id"), "bankseq")` method is used for the `Id` property. If a migration is rolled back, the tables and sequence will be dropped. Changes: 1. Creation of a new database schema `SettlementBankDB` and two new tables `banks` and `IntegrationEventLog` in the files `20240302181923_InitialCreate.Designer.cs`, `20240302181923_InitialCreate.cs`, and `SettlementBankContextModelSnapshot.cs`. 2. The `banks` table has five columns: `Id`, `Bic`, `Country`, `Name`, and `Code`. The `Id` column is the primary key and there are unique indexes on the `Bic` column. 3. The `IntegrationEventLog` table has seven columns: `EventId`, `EventTypeName`, `State`, `TimesSent`, `CreationTime`, `Content`, and `TransactionId`. The `EventId` column is the primary key. 4. A sequence named `bankseq` is created which increments by 10. 5. The `ProductVersion` is set to `8.0.2` and `Relational:MaxIdentifierLength` is set to `63`. 6. The `NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder)` method is called. 7. The `NpgsqlPropertyBuilderExtensions.UseHiLo(b.Property<int>("Id"), "bankseq")` method is used for the `Id` property. 8. If a migration is rolled back, the `banks` and `IntegrationEventLog` tables and the `bankseq` sequence will be dropped. This is indicated in the `Down` method in the `20240302181923_InitialCreate.cs` file.
…s that extend the functionality of the application. These include `AuthenticationExtensions.cs`, `ClaimsPrincipalExtensions.cs`, `ConfigurationExtensions.cs`, `Extensions.cs`, `HttpClientExtensions.cs`, and `OpenApi.Extensions.cs`. Each of these files contains a static class with methods that provide various functionalities such as configuring authentication and authorization services, extracting user information from claims, getting required values from the configuration, configuring application services, adding an authorization token to the HTTP client, and configuring OpenAPI documentation. Additionally, the `PruebaTecnicaNet.ServiceDefaults.csproj` file has been modified to include several new package references and to set the target framework to .NET 8.0. Changes: 1. `AuthenticationExtensions.cs` has been added. It contains a static class `AuthenticationExtensions` with a method `AddDefaultAuthentication` for configuring the authentication and authorization services using JWT Bearer authentication (AuthenticationExtensions.cs). 2. `ClaimsPrincipalExtensions.cs` has been added. It contains a static class `ClaimsPrincipalExtensions` with methods `GetUserId` and `GetUserName` for extracting user information from claims (ClaimsPrincipalExtensions.cs). 3. `ConfigurationExtensions.cs` has been added. It contains a static class `ConfigurationExtensions` with a method `GetRequiredValue` for getting required values from the configuration (ConfigurationExtensions.cs). 4. `Extensions.cs` has been added. It contains a static class `Extensions` with methods for configuring application services (Extensions.cs). 5. `HttpClientExtensions.cs` has been added. It contains a static class `HttpClientExtensions` with a method `AddAuthToken` for adding an authorization token to the HTTP client (HttpClientExtensions.cs). 6. `OpenApi.Extensions.cs` has been added. It contains a static class `Extensions` with methods for configuring OpenAPI documentation (OpenApi.Extensions.cs). 7. `PruebaTecnicaNet.ServiceDefaults.csproj` has been modified to include new package references and to set the target framework to .NET 8.0 (PruebaTecnicaNet.ServiceDefaults.csproj).
…ActivityExtensions.cs` and `MigrateDbContextExtensions.cs`, which contain static classes for handling exception tags and database migrations respectively. In `ActivityExtensions.cs`, a new static class `ActivityExtensions` has been added. This class contains a method `SetExceptionTags` which is an extension method for the `Activity` class. This method is used to add tags to an `Activity` instance related to an exception such as the exception message, stack trace, and type. It also sets the status of the `Activity` to `Error`. In `MigrateDbContextExtensions.cs`, a new static class `MigrateDbContextExtensions` has been added. This class contains several methods related to database migrations. The `AddMigration` methods are extension methods for `IServiceCollection` that add migration services for a specific `DbContext`. The `MigrateDbContextAsync` method is an extension method for `IServiceProvider` that migrates a specific `DbContext` and invokes a seeder function. The `InvokeSeeder` method and `MigrationHostedService` class are used to migrate a specific `DbContext` and invoke a seeder function. A new public interface `IDbSeeder` has been added which contains a method `SeedAsync` for seeding a specific `DbContext`. Changes: 1. Addition of `ActivityExtensions.cs` file with `ActivityExtensions` static class and `SetExceptionTags` method. 2. Addition of `MigrateDbContextExtensions.cs` file with `MigrateDbContextExtensions` static class, `AddMigration` methods, `MigrateDbContextAsync` method, `InvokeSeeder` method, and `MigrationHostedService` class. 3. Addition of `IDbSeeder` interface with `SeedAsync` method.
…s to the project. These files include `ActivityExtensions.cs`, `EventBusOptions.cs`, `EventBusRabbitMQ.csproj`, `GlobalUsings.cs`, `RabbitMQEventBus.cs`, `RabbitMQTelemetry.cs`, and `RabbitMqDependencyInjectionExtensions.cs`. 1. `ActivityExtensions.cs`: This new file contains an extension method for the `Activity` class, which sets exception tags for OpenTelemetry tracing. This change enhances the project's tracing capabilities. 2. `EventBusOptions.cs`: This file has been added to represent configuration options for the event bus, including the subscription client name and retry count. This change provides a way to configure the event bus. 3. `EventBusRabbitMQ.csproj`: This new file contains the project configuration for the EventBusRabbitMQ project, including target framework, root namespace, and package references. This change sets up the project configuration for EventBusRabbitMQ. 4. `GlobalUsings.cs`: This file has been added to contain global using directives for the project, which simplifies the code by eliminating the need for explicit using directives in every file. This change simplifies the codebase. 5. `RabbitMQEventBus.cs`: This new file contains the implementation of the `IEventBus` interface using RabbitMQ. It includes methods for publishing events, processing received events, and handling exceptions. This change provides the implementation of the event bus using RabbitMQ. 6. `RabbitMQTelemetry.cs`: This file has been added to provide OpenTelemetry tracing for RabbitMQ. This change enhances the project's tracing capabilities. 7. `RabbitMqDependencyInjectionExtensions.cs`: This new file contains extension methods for the `IHostApplicationBuilder` interface, which add RabbitMQ event bus services to the application's dependency injection container. This change integrates RabbitMQ event bus services into the application's dependency injection container.
…support a .NET application, the inclusion of global using directives in the GlobalUsings.cs file, the comprehensive description of the API's endpoints in the openapi.json file, and the addition of new profiles in the launchSettings.json file for running the application in different environments. 1. The Dockerfile has been updated to include instructions for building and running a .NET application. It specifies the base image to use, sets the user and working directory, exposes ports 8080 and 8081, copies the project files into the container, restores the .NET dependencies, builds the application, and finally sets the entrypoint for the application. 2. The GlobalUsings.cs file has been updated to include global using directives for various namespaces. This means that these namespaces are now available for use throughout the entire project without needing to be explicitly declared in each file. 3. The openapi.json file has been updated to include a comprehensive description of the API's endpoints, parameters, responses, and data schemas. This file is typically used for generating documentation and client SDKs for the API. 4. The launchSettings.json file has been updated with new profiles for running the application in different environments such as HTTP, HTTPS, IIS Express, Docker, and WSL. These profiles include settings for the command to run, whether to launch the browser, the launch URL, environment variables, and more. Other changes include updates to the Program.cs, PuebaTecnicaNet.API.csproj, PuebaTecnicaNet.API.http, appsettings.Development.json, appsettings.json, and docker-compose.yml files. These updates include the addition of new code, project properties, package references, GET requests, connection strings, logging levels, allowed hosts, OpenApi details, EventBus details, Identity details, and eSettAPI base address, and new services for a Postgres database and adminer.
…onents to the EsettClient API and the generation of a REST API client for the `eSettopendataAPI`. The new components added to the EsettClient API include new schemas for different data objects and new paths defining the endpoints for various operations. The schemas define the properties of the respective data objects, while the paths define the operations, required parameters, and expected responses. The REST API client for the `eSettopendataAPI` is auto-generated using the NSwag toolchain. It includes methods to interact with the API, specifically to get a list of settlement banks. The client also includes error handling to manage different HTTP status codes and potential issues with deserialization. Changes: 1. Addition of new components to the EsettClient API, including new schemas for different data objects and new paths defining the endpoints for various operations. (Refer to the code changes in the EsettClient API) 2. Generation of a REST API client for the `eSettopendataAPI` using the NSwag toolchain. This client includes methods to interact with the API and error handling. (Refer to the code changes in the `eSettopendataAPIClient` class) 3. The `BanksAsync` method in the `eSettopendataAPIClient` class is overloaded to allow for cancellation of the request. (Refer to the code changes in the `BanksAsync` method) 4. The base URL for the API is set to "https://api.opendata.esett.com". (Refer to the code changes in the `eSettopendataAPIClient` class) 5. Several compiler warnings are disabled at the start of the code and then restored at the end to avoid issues with the auto-generated code. (Refer to the code changes in the `eSettopendataAPIClient` class) 6. The namespace for the client is `PruebaTecnicaNet.API`. (Refer to the code changes in the `eSettopendataAPIClient` class)
…ateDbContextExtensions.cs` in the `Microsoft.AspNetCore.Hosting` namespace. This file contains a static class `MigrateDbContextExtensions` that provides extension methods for `IServiceCollection` to add and manage database migrations for a `DbContext`. The class also includes a private readonly string `ActivitySourceName` and an `ActivitySource` object for tracing migration activities. Three public methods are added to the `IServiceCollection` to manage migrations and seeding of the database. Two private methods are added to handle the migration and seeding process. A private class `MigrationHostedService<TContext>` is also added, which inherits from `BackgroundService` and overrides the `StartAsync` and `ExecuteAsync` methods to manage the migration process. The `ILogger<TContext>` service is used to log information and error messages during the migration process. The `ActivitySource` object is used to start activities for tracing the migration process and setting exception tags in case of errors. List of changes: 1. Creation of a new file `MigrateDbContextExtensions.cs` in the `Microsoft.AspNetCore.Hosting` namespace. 2. Addition of a static class `MigrateDbContextExtensions` with extension methods for `IServiceCollection`. 3. Addition of three public methods to `IServiceCollection`: `AddMigration<TContext>`, `AddMigration<TContext, TDbSeeder>`. 4. Addition of two private methods: `MigrateDbContextAsync<TContext>`, `InvokeSeeder<TContext>`. 5. Addition of a private class `MigrationHostedService<TContext>` that inherits from `BackgroundService`. 6. Use of `ILogger<TContext>` service for logging during the migration process. 7. Use of `ActivitySource` object for tracing the migration process and setting exception tags.
…`PruebaTecnicaNet.API.Extensions` and the addition of a new static class `LinqSelectExtensions` within this namespace. This class contains three new public static methods: `SelectTry<TSource, TResult>`, `OnCaughtException<TSource, TResult>`, and two overloads of `OnCaughtException<TSource, TResult>`. Additionally, a new public class `SelectTryResult<TSource, TResult>` has been added inside the `LinqSelectExtensions` class. List of Changes: 1. A new namespace `PruebaTecnicaNet.API.Extensions` has been added. This namespace will contain the new static class and its methods. 2. A new static class `LinqSelectExtensions` has been created within the `PruebaTecnicaNet.API.Extensions` namespace. This class will contain the new methods and class. 3. Three new public static methods have been added to the `LinqSelectExtensions` class: - `SelectTry<TSource, TResult>`: This method takes an `IEnumerable<TSource>` and a function `selector` as parameters. It applies the selector function to each element in the enumerable and returns a new `SelectTryResult<TSource, TResult>` object. If an exception occurs during the execution of the selector function, it is caught and included in the `SelectTryResult<TSource, TResult>` object. - `OnCaughtException<TSource, TResult>`: This method is overloaded twice. The first overload takes an `IEnumerable<SelectTryResult<TSource, TResult>>` and a function `exceptionHandler` as parameters. It applies the exceptionHandler function to the `CaughtException` property of each `SelectTryResult<TSource, TResult>` object in the enumerable. The second overload takes an additional function `exceptionHandler` that also includes the `Source` property of the `SelectTryResult<TSource, TResult>` object. 4. A new public class `SelectTryResult<TSource, TResult>` has been added inside the `LinqSelectExtensions` class. This class has three properties: `Source`, `Result`, and `CaughtException`. It also has a constructor that takes three parameters corresponding to these properties. This class is used to handle exceptions that occur during the execution of the `SelectTry<TSource, TResult>` method.
…named `IDbSeeder` within the `Microsoft.AspNetCore.Hosting` namespace. This interface is generic and takes a type parameter `TContext` that must be a `DbContext` type. The interface also declares a single method `SeedAsync` that is likely used for asynchronous database seeding. List of Changes: 1. A new interface `IDbSeeder` has been added to the `Microsoft.AspNetCore.Hosting` namespace. This interface is designed to work with database seeding operations. 2. The `IDbSeeder` interface is generic and takes a type parameter `TContext`. This parameter is constrained to be a type of `DbContext`, ensuring that it can be used with various types of database contexts. 3. The `IDbSeeder` interface declares a single method `SeedAsync`. This method takes an argument of type `TContext` and returns a `Task`. The purpose of this method is likely to seed the database asynchronously, allowing for efficient and non-blocking operations. References to Code Changes: - Addition of `IDbSeeder` interface: `Microsoft.AspNetCore.Hosting.IDbSeeder` - Generic type parameter `TContext` in `IDbSeeder`: `Microsoft.AspNetCore.Hosting.IDbSeeder<TContext>` - Declaration of `SeedAsync` method in `IDbSeeder`: `Microsoft.AspNetCore.Hosting.IDbSeeder.SeedAsync(TContext)`
…ss `Extensions` and the introduction of several namespaces to the `Extensions.cs` file. The `Extensions` class contains two methods, `AddApplicationServices` and `AddEventBusSubscriptions`, which are used to add services to the application and subscriptions to the event bus, respectively. The `AddApplicationServices` method includes several important changes such as disabling DbContext pooling for the `SettlementBankContext`, adding migration for the same, and adding various services like `IIntegrationEventLogService`, `ISettlementBankIntegrationEventService`, RabbitMQ event bus, and event bus subscriptions. It also configures MediatR and adds behaviors for logging and validation, registers the validator for the `CreateSettlementBankCommand`, and adds scoped services for `ISettlementBankQueries`, `ISettlementBankRepository`, and `IRequestManager`. The `AddEventBusSubscriptions` method adds a subscription for the `SettlementBankUpdatedSucceedIntegrationEvent`. Changes: 1. Addition of several namespaces to the `Extensions.cs` file. 2. Addition of a new static class `Extensions`. 3. Addition of the `AddApplicationServices` method to the `Extensions` class. 4. Disabling of DbContext pooling for the `SettlementBankContext` in the `AddApplicationServices` method. 5. Addition of migration for the `SettlementBankContext` in the `AddApplicationServices` method. 6. Addition of various services in the `AddApplicationServices` method. 7. Configuration of MediatR and addition of behaviors for logging and validation in the `AddApplicationServices` method. 8. Registration of the validator for the `CreateSettlementBankCommand` in the `AddApplicationServices` method. 9. Addition of scoped services in the `AddApplicationServices` method. 10. Addition of the `AddEventBusSubscriptions` method to the `Extensions` class. 11. Addition of a subscription for the `SettlementBankUpdatedSucceedIntegrationEvent` in the `AddEventBusSubscriptions` method.
…ss `ActivityExtensions` in the `ActivityExtensions.cs` file. This class includes a method `SetExceptionTags` that extends the `Activity` class. The method takes an `Activity` and an `Exception` object as parameters and adds three tags to the `Activity` object if it is not null. These tags include the exception message, stack trace, and type. The method also sets the status of the `Activity` object to `ActivityStatusCode.Error` and follows the OpenTelemetry specifications for exception handling. List of changes: 1. A new static class `ActivityExtensions` has been added to the `ActivityExtensions.cs` file. This class contains a method `SetExceptionTags` which extends the `Activity` class. 2. The `SetExceptionTags` method takes an `Activity` object and an `Exception` object as parameters. If the `Activity` object is null, the method returns without doing anything. 3. If the `Activity` object is not null, the method adds three tags to the `Activity` object: "exception.message" with the message of the exception, "exception.stacktrace" with the full stack trace of the exception, and "exception.type" with the full name of the exception's type. 4. After adding the tags, the method sets the status of the `Activity` object to `ActivityStatusCode.Error`. 5. The method is designed to follow the OpenTelemetry specifications for exception handling, as indicated by the comment at the beginning of the method.
… the creation of a new public class, and the addition of an asynchronous method within this class. 1. A new namespace `PruebaTecnicaNet.API.Infrastructure` has been added. This change suggests that new functionalities related to infrastructure are being introduced in the API. 2. Several new `using` directives have been added, which are `PruebaTecnicaNet.API`, `PruebaTecnicaNet.Domain.SettlementBankAggregate`, `PruebaTecnicaNet.Infraestructure`, and `System.Threading.Tasks`. These directives indicate that the code in the file is using types defined in other namespaces. 3. A new public class `SettlementBankContextSeed` has been created which implements the `IDbSeeder<SettlementBankContext>` interface. This class is likely to be used for seeding data into the `SettlementBankContext` database. 4. Inside the `SettlementBankContextSeed` class, an asynchronous method `SeedAsync` has been added which takes an instance of `SettlementBankContext` as a parameter. This method is responsible for seeding data into the database. 5. Inside the `SeedAsync` method, the `SaveChangesAsync` method is called on the `context` object. This method is used to save all changes made in the `SettlementBankContext` to the underlying database. This indicates that the `SeedAsync` method is not only responsible for creating the data but also for saving it to the database.
…PruebaTecnicaNetApi` in the `PruebaTecnicaNetApi.cs` file and a new class `SettlementBankServices` in the `SettlementBankServices.cs` file. The `PruebaTecnicaNetApi` class contains methods for fetching settlement banks and saving them in the database, while the `SettlementBankServices` class handles the business logic related to settlement banks. Changes: 1. In `PruebaTecnicaNetApi.cs`, a new static class `PruebaTecnicaNetApi` was added. This class contains three HTTP GET methods: `GetsettlementbanksAsync`, `GetsettlementbankAsync`, and `GetSettlementBanksFromEsettAsync`. These methods are used to fetch all settlement banks, fetch a settlement bank by its id, and load the settlement banks from the esett API and save them in the database respectively. The class also includes a method `MapPruebaTecnicaNetApi` to map these endpoints. 2. In `SettlementBankServices.cs`, a new class `SettlementBankServices` was added. This class contains properties for `IMediator`, `ILogger<SettlementBankServices>`, and `ISettlementBankQueries`. It also includes a constructor that initializes these properties. This class is used to handle the business logic related to settlement banks.
… `ISettlementBankQueries`, and its corresponding implementation, `SettlementBankQueries`, in the `PruebaTecnicaNet.API.Queries` namespace. These additions provide methods for retrieving settlement bank information. Additionally, a new record `SettlementBank` was added to the `SettlementBankViewModel.cs` file, which defines the structure of a settlement bank. Changes: 1. An empty class `AppSettings.cs` was added to the `PruebaTecnicaNet.API.Queries` namespace. This file currently does not contain any code. 2. The `ISettlementBankQueries` interface was added to the `PruebaTecnicaNet.API.Queries` namespace. This interface defines three methods for retrieving settlement bank information: `GetSettlementBankAsync`, `GetSettlementBanksAsync`, and `GetSettlementBanksFromEsettAsync`. 3. The `SettlementBankQueries` class was added to the `PruebaTecnicaNet.API.Queries` namespace. This class implements the `ISettlementBankQueries` interface, providing the implementation for the three methods defined in the interface. 4. A new record `SettlementBank` was added to the `SettlementBankViewModel.cs` file in the `PruebaTecnicaNet.API.Queries` namespace. This record defines the structure of a settlement bank with three properties: `Bic`, `Country`, and `Name`.
…andle integration events related to the updating of settlement banks. These changes include the creation of a new event handler, an integration event record, an interface for the integration event service, and the implementation of this interface. 1. A new file, `SettlementBankUpdatedSucceedIntegrationEventHandler.cs`, has been added. This file contains a class that implements the `IIntegrationEventHandler` interface, logging the handling of an integration event and sending a `CreateSettlementBankCommand` command. 2. The `SettlementBankUpdatedSucceedIntegrationEvent.cs` file has been added. This file contains a record that inherits from the `IntegrationEvent` class and includes three properties: `Bic`, `Name`, and `Country`. 3. A new interface, `ISettlementBankIntegrationEventService`, has been added in the `ISettlementBankIntegrationEventService.cs` file. This interface declares two methods for publishing and saving events. 4. The `SettlementBankIntegrationEventService.cs` file has been added. This file contains a class that implements the `ISettlementBankIntegrationEventService` interface. The class includes methods for retrieving and publishing pending event logs, handling errors during publishing, and logging and saving events.
…ateSettlementBankCommandValidator` and the definition of its constructor. The class is designed to validate the properties of the `CreateSettlementBankCommand` object. Additionally, a conditional statement is added to log trace information when an instance of the class is created. 1. A new class `CreateSettlementBankCommandValidator` is created in the `PruebaTecnicaNet.API.Application.Validations` namespace. This class inherits from the `AbstractValidator<CreateSettlementBankCommand>` class. 2. A constructor for the `CreateSettlementBankCommandValidator` class is defined. It accepts an `ILogger<CreateSettlementBankCommandValidator>` object as a parameter. 3. Inside the constructor, validation rules for the `Bic`, `Name`, and `Country` properties of the `CreateSettlementBankCommand` object are defined. The `Bic` and `Country` properties must not be empty and must have lengths of 8 and 2 respectively, while the `Name` property must not be empty. 4. A conditional statement is added to check if the logger's log level is set to `Trace`. If it is, a trace log is written indicating that an instance of the `CreateSettlementBankCommandValidator` class has been created.
…of a new interface `ISettlementBankQueries` and its implementation in the `SettlementBankQueries` class. These changes are designed to facilitate querying settlement banks. A new model class `SettlementBank` has also been added to represent a settlement bank. 1. A new interface `ISettlementBankQueries` has been added in the `ISettlementBankQueries.cs` file. This interface declares three methods: `GetSettlementBankAsync`, `GetSettlementBanksAsync`, and `GetSettlementBanksFromEsettAsync`. These methods are designed to return a single `SettlementBank` object, a collection of `SettlementBank` objects, and a collection of `SettlementBank` objects from Esett respectively. 2. The `SettlementBankQueries.cs` file now contains a new class `SettlementBankQueries` that implements the `ISettlementBankQueries` interface. This class provides the implementation for the three methods declared in the interface. The `GetSettlementBankAsync` method retrieves a single `SettlementBank` object based on the provided id. The `GetSettlementBanksAsync` method retrieves a collection of `SettlementBank` objects. The `GetSettlementBanksFromEsettAsync` method retrieves a collection of `SettlementBank` objects from Esett. 3. A new class `SettlementBank` has been added in the `SettlementBankViewModel.cs` file. This class represents the model for a settlement bank with properties `Bic`, `Name`, and `Country`.
…and handlers to manage the creation of settlement banks and ensure idempotency in the command process. 1. `CreateSettlementBankCommand.cs` has been updated to include a new command class `CreateSettlementBankCommand` that implements `IRequest<bool>`. This class is used to create a new settlement bank with properties `Bic`, `Name`, and `Country` which are set through the constructor and are read-only after being set. 2. `CreateSettlementBankCommandHandler.cs` has been updated to include two new command handler classes. The `CreateSettlementBankCommandHandler` class implements `IRequestHandler<CreateSettlementBankCommand, bool>` and contains the logic for handling the `CreateSettlementBankCommand`. The `CreateSettlementBankIdentifiedCommandHandler` class extends `IdentifiedCommandHandler<CreateSettlementBankCommand, bool>` and is used for ensuring idempotency in the command process. 3. `IdentifiedCommand.cs` has been updated to include a new class `IdentifiedCommand<T, R>` which implements `IRequest<R>`. This class is used to wrap a command and an ID together to check for duplicate requests. 4. `IdentifiedCommandHandler.cs` has been updated to include a new abstract class `IdentifiedCommandHandler<T, R>` which implements `IRequestHandler<IdentifiedCommand<T, R>, R>`. This class provides a base implementation for handling duplicate requests and ensuring idempotent updates.
…of new classes that implement the `IPipelineBehavior` interface. These classes are `LoggingBehavior`, `TransactionBehavior`, and `ValidatorBehavior`, which are used to handle logging, transactions, and validation respectively in the application. 1. `LoggingBehavior.cs`: A new class `LoggingBehavior` is added. This class logs information about the handling of commands in the application, including the name of the command being handled and the response from the command. 2. `TransactionBehavior.cs`: A new class `TransactionBehavior` is added. This class handles transactions in the application. It checks for an active transaction, creates a new one if none exists, executes the command, logs transaction information, and publishes events through the event bus. 3. `ValidatorBehavior.cs`: A new class `ValidatorBehavior` is added. This class validates commands in the application. It checks for validation errors, logs them, and throws a `SettlementBankException` if any errors are found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Muchas gracias por la prueba técnica, me parece correcto el desarrollo y la forma de escribir código, hablaré con Alvaro para que continúes con el proceso de selección.
Aquí dejaré mis comentarios constructivos:
- Añadir comentarios a las funciones métodos y clases
- Extensos ficheros, tenemos como política no exceder las 160 líneas de código, y explotar las herencias.
- Excelente manejo de excepciones
- Buen dominio de la tecnología
|
||
// Additional code | ||
|
||
public SettlementBank(string bic, string country, string name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Una breve documentación de lo que hace la clase.
} | ||
} | ||
|
||
public bool IsBicValid(string bic) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me gusta mucho que se haga este tipo de criterios
return name.Length > 0; | ||
} | ||
|
||
public bool IsValid() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Positivo al ver este tipo métodos, en mi caso usualmente los convierto en propiedades
} | ||
|
||
// Invalid Bic | ||
public class InvalidBicException : SettlementBankException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excelente dominio de validación de excepciones
Esta es una propuesta para resolver el ejercicio con las siguientes arquitecturas: Microservicio CQRS-ES DDD