1plam / fleetjourney Goto Github PK
View Code? Open in Web Editor NEWSoftware created to simplify the process of recording business trips made by TheGreenMile™ employees using their fleet of electric cars.
License: GNU General Public License v3.0
Software created to simplify the process of recording business trips made by TheGreenMile™ employees using their fleet of electric cars.
License: GNU General Public License v3.0
Due to the current unavailability of checking if the employee and trip exist, an EF Core exception is thrown whenever non-existent details are provided. This issue occurs because there is no proper check in place. Attempts to use AnyAsync
, ContainsAsync
, and Where
methods have been unsuccessful. The proposed solution is to create a self-implemented wrapper-extensions method.
The issue occurs specifically in the Create and Update methods within the TripRepository
class.
public async Task<bool> CreateAsync(Trip trip, CancellationToken cancellationToken)
{
await _applicationDbContext.Trips.AddAsync(trip, cancellationToken);
int result = await _applicationDbContext.SaveChangesAsync(cancellationToken);
return result > 0;
}
public async Task<Trip?> UpdateAsync(Trip trip, CancellationToken cancellationToken)
{
_applicationDbContext.Trips.Update(trip);
await _applicationDbContext.SaveChangesAsync(cancellationToken);
return trip;
}
The CreateAsync and UpdateAsync methods should include proper checks to verify the existence of the employee and trip. If the employee or trip is not found, appropriate error handling should be implemented, such as returning false or throwing an exception.
To address this issue, a self-implemented wrapper-extensions method should be created to check if the employee and trip exist before proceeding with the Create and Update operations.
When running the application, an unhandled exception is thrown, indicating that some services are not able to be constructed. The exception occurs while validating the service descriptors for various handlers and repositories. It appears that the issue arises from the inability to resolve the required dependencies, specifically the IRepository interface, which is not being injected into the corresponding APIs.
Steps to Reproduce:
Expected Behavior:
The application should start successfully without any exceptions related to service construction/validation and direct injection of IRepository.
Actual Behavior:
The application throws an unhandled exception due to the inability to construct certain handlers and resolve dependencies.
Root Cause:
The root cause of the exception is the missing injection of the IRepository
interface into the APIs mentioned above. This causes an issue of unavailability to inject needed handlers without injecting each repository to Mediator.
Proposed Solution:
To resolve the exception and ensure proper dependency injection, the step of injection each repository in to each API has to be followed:
builder.Services.AddApplicationService(typeof(IRepository<,>));
While the proposed solution of injecting each repository into the APIs may resolve the exception and ensure proper dependency injection, it is not an ideal approach. Injecting multiple repositories directly into the APIs can lead to tight coupling and violation of the SRP.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.