Coder Social home page Coder Social logo

1plam / fleetjourney Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 63.24 MB

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

Dockerfile 1.05% C# 54.38% HTML 0.20% JavaScript 2.10% TypeScript 39.97% CSS 2.30%
aws-sqs clean-architecture cqrs-pattern csharp docker entity-framework-core kubernetes mediator ocelot-api-gateway react restful-api scrutor typescript

fleetjourney's People

Contributors

1plam avatar

Watchers

 avatar

fleetjourney's Issues

Exception when providing non-existent employee or trip details in TripRepository Create and Update methods.

Description

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.

Repository File

  • TripRepository.cs

Steps to Reproduce

  1. Perform the Create or Update operation with non-existent employee or trip details.
  2. Observe the EF Core exception that is thrown.

Code Snippet:

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;
}

Expected Behavior

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.

Proposed Solution

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.

Mediator Problems Due to Missing IRepository Injection in APIs

Description:

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:

  1. Build and run the application.
  2. Observe the unhandled exception being thrown.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.