Git Product home page Git Product logo

itl's Introduction

ITL

Sample Web API implementation with .NET Core and DDD using Clean Architecture.

Solution Design

The solution design focuses on a basic Domain Driven Design techniques and implementation, while keeping the things as simple as possible but can be extended as needed. Multiple assemblies are used for separation of concerns to keep logic isolated from the other components. .NET 7 C# is the default framework and language for this application.

Assembly Layers

  • ITL.Domain - This assembly contains common, entities and interfaces.
  • ITL.Application - This assembly contains all services implementations.
  • ITL.Infrastructure - This assembly contains the infrastructure of data persistence.
  • ITL.API - This assembly is the web api host.
  • ITL.Tests - This assembly contains unit test classes based on the NUnit testing framework.

How to contribute

💭 If you are new in Open Source world feel free to check our How to contribute guidelines

Validation

Data validation using FluentValidation

How to run application:

(Backend)

  1. Create empty database, name: KCTest.
  2. Execute migrations.
  3. Set connection string (in appsettings.json or by user secrets mechanism).
  4. Run .. .

(kctest-frontend)

Follow the instructions in README file.

¡Give a Star!

If you like this project, learn something or you are using it in your applications, please give it a star. Thanks! .. .

License

This project is open source and available under the -> MIT License

itl's People

Contributors

dependabot[bot] avatar depfu[bot] avatar jadhielv avatar morzkat avatar nminaya avatar shamirvaldez avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

itl's Issues

IStringLocalizer in Application project

Hello,

The application is multilanguage means, I have to return an error message in the right language.

When I do this in the API project, it's ok I get the right value for Article
image

In the Startup.cs

services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddControllersWithViews()
        .AddViewLocalization
        (LanguageViewLocationExpanderFormat.Suffix)
        .AddDataAnnotationsLocalization();
services.Configure<RequestLocalizationOptions>(options => {
    var supportedCultures = new[] { "fr-BE", "nl-BE", "en-US" };
    options.SetDefaultCulture(supportedCultures[0])
        .AddSupportedCultures(supportedCultures)
        .AddSupportedUICultures(supportedCultures);
});

In the controller :

private readonly IStringLocalizer<MyController> _localizer;
public MyController(IStringLocalizer<MyController> localizer)
{    _localizer = localizer; }

public ActionResult Get()
{   var article = _localizer["Article"];
    return Ok();
}

But I have to use that in the Application project

Then I do this :

public class MyService : IMyService
{
   private readonly IStringLocalizer<MyService> _localization;
    public MyService(IStringLocalizer<MyService> localization)
    {
	_localization = localization;
    }	
    public void Search()
    {
        var res = _localization["Article"];
    }
}

In res I get the value Article (the key) but not the value, I tried to move the resources files to Application project but still not work.

How can I do to fix this ?

Thanks

Query in nested object (Update)

    You can filter using LinQ:

var product = await _unitOfWork.Products.Where(x => x.Id == id).Select(x => new ProductDto { x.Name, ActiveProductPrices = x.ProductPrices.Where(p => p.IsActive) }).First();

Does not work because you don't have access Products but you have access to ProductRepository.

Originally posted by @nminaya in #220 (comment)

Update all the packages listed

Is your feature request related to a problem? Please describe.
Update dependencies and devDependencies to the latest version

Describe the solution you'd like
Use npm-update

Describe alternatives you've considered
NONE

Additional context
NONE

Npm install error

Running npm install command in the kctest-frontend folder throws the following error:

image

How add custom method in Repository

Hello,

I'd like add a custom method in the PermissionRepository but I don't have access to the DBSet of the base class Repository.

What is the best way to do this ?

Thanks,

Crosscutting project ?

Hello,

I need to use some enums in Application or Domain, it's not a good idea to create a crosscutting project to place these enums ? Same for exceptions, in Application you can throw an exception catched in the Middleware in the API.

Thanks,

Add some unit tests

Describe alternatives you've considered
Unit Test Through Mocking Using Moq Framework.

Additional context
NONE

Create contributing guidelines

Is your feature request related to a problem? Please describe.
The purpose is describing how others may contribute content to the project.

Describe the solution you'd like
Use Good-CONTRIBUTING.md-template or whatever you prefer.

Describe alternatives you've considered
NONE

Additional context
NONE

Query in nested object

Hello,

See explanation in 'MyMethod'

thanks,

public class Product : BaseEntity
{
    public string Name { get; set; }
    public ICollection<ProductPrice> ProductPrices { get; set; }
}

public class ProductPrice : BaseEntity
{
    [Column(TypeName = "decimal(18, 2)")]
    public decimal Price { get; set; }
    public bool IsActive { get; set; }
    public Product Product { get; set; }
}

public async Task<Product> MyMethod (int id)
{

   // In the query below, I'd like get in the result, the ProductPrice collection but only the Product where IsActive is true
   // how do this with your generic repo ?

   var product = await _unitOfWork.Products.First(x => x.Id == id);   
    
   return product;
}

Update to .NET 6.0

  • Migrate from ASP.NET Core 5.0 to 6.0
  • Change the target framework of all projects.
<TargetFramework>net6.0</TargetFramework>

[TODO]: Find a way to inject the repositories and share the same context without creating an instance.

//TODO: Find a way to inject the repositories and share the same context without creating a instance.

In C#, you can use the Dependency Injection (DI) pattern to provide instances of repositories to your application without having to create an instance of each repository yourself. If you require any further information, please do not hesitate to contact me or our collaborator, @nminaya, he can provide more details.

Repositories of the UOW

Instead of create a new instance of the repositories you can use DI (because you already have the interfaces) for inject the repositories the UOW needs.

Test suite failed to run

Is your feature request related to a problem?
FAIL test/e2e/specs/test.js

● Test suite failed to run

Your test suite must contain at least one test.

  at onResult (D:\Repositories (GitHub)../../../KCTest/kctest-frontend/node_modules/@jest/core/build/TestScheduler.js:175:18)
  at D:\Repositories (GitHub)../../../KCTest/kctest-frontend/node_modules/@jest/core/build/TestScheduler.js:304:17
  at D:\Repositories (GitHub)../../../KCTest/kctest-frontend/node_modules/emittery/index.js:260:13
      at Array.map (<anonymous>)
  at Emittery.Typed.emit (D:\Repositories (GitHub)../../../KCTest/kctest-frontend/node_modules/emittery/index.js:258:23)

FAIL test/unit/specs/HelloWorld.spec.js
● Test suite failed to run

Configuration error:

Could not locate module @/components/HelloWorld mapped as:
D:\Repositories (GitHub)\KCTest\kctest-frontend\src\$1.

Please check your configuration for these entries:
{
  "moduleNameMapper": {
    "/^@\/(.*)$/": "D:\Repositories (GitHub)\KCTest\kctest-frontend\src\$1"
  },
  "resolver": undefined
}

  1 | import Vue from 'vue'
> 2 | import HelloWorld from '@/components/HelloWorld'
    | ^
  3 | 
  4 | describe('HelloWorld.vue', () => {
  5 |   it('should render correct contents', () => {

  at createNoMappedModuleFoundError (D:\Repositories (GitHub)../../../KCTest/kctest-frontend/node_modules/jest-resolve/build/index.js:551:17)
  at Object.<anonymous> (D:\Repositories (GitHub)../../../KCTest/kctest-frontend/test/unit/specs/HelloWorld.spec.js:2:1)

Describe the solution you'd like
Adjust Configuration of Jest. Documentation: https://jestjs.io/docs/en/configuration

Describe alternatives you've considered
NONE

Additional context
NONE

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.