All Projects → rabbal → Dntframeworkcore

rabbal / Dntframeworkcore

Licence: apache-2.0
Lightweight and Extensible Infrastructure for Building Web Applications - Web Application Framework

Projects that are alternatives of or similar to Dntframeworkcore

Dotnet New Caju
Learn Clean Architecture with .NET Core 3.0 🔥
Stars: ✭ 228 (+9.62%)
Mutual labels:  event-driven, solid, design-patterns, cqrs
Event Sourcing Jambo
An Hexagonal Architecture with DDD + Aggregates + Event Sourcing using .NET Core, Kafka e MongoDB (Blog Engine)
Stars: ✭ 159 (-23.56%)
Mutual labels:  event-driven, solid, dotnet-core, cqrs
Qframework
Unity3D System Design Architecture
Stars: ✭ 2,326 (+1018.27%)
Mutual labels:  framework, cqrs, event-driven
Hexagonal Architecture Acerola
An Hexagonal Architecture service template with DDD, CQRS, TDD and SOLID using .NET Core 2.0. All small features are testable and could be mocked. Adapters could be mocked or exchanged.
Stars: ✭ 293 (+40.87%)
Mutual labels:  solid, dotnet-core, cqrs
Revo
Event Sourcing, CQRS and DDD framework for C#/.NET Core.
Stars: ✭ 162 (-22.12%)
Mutual labels:  framework, aspnet-core, cqrs
Run Aspnetcore
A starter kit for your next ASP.NET Core web application. Boilerplate for ASP.NET Core reference application, demonstrating a layered application architecture with applying Clean Architecture and DDD best practices. Download 100+ page eBook PDF from here ->
Stars: ✭ 227 (+9.13%)
Mutual labels:  aspnet-core, dotnet-core, design-patterns
Stove
Domain Driven Design oriented application framework, meets CRUD needs
Stars: ✭ 160 (-23.08%)
Mutual labels:  transaction, framework, cqrs
Architecture
.NET 6, ASP.NET Core 6, Entity Framework Core 6, C# 10, Angular 13, Clean Code, SOLID, DDD.
Stars: ✭ 2,285 (+998.56%)
Mutual labels:  solid, aspnet-core, dotnet-core
Service Pattern Go
Simple clean Go REST API architecture with dependency injection and mocking example, following SOLID principles.
Stars: ✭ 449 (+115.87%)
Mutual labels:  solid, design-patterns, unit-testing
Jsonapidotnetcore
JSON:API Framework for ASP.NET Core
Stars: ✭ 465 (+123.56%)
Mutual labels:  crud, aspnet-core, dotnet-core
Event Sourcing Castanha
An Event Sourcing service template with DDD, TDD and SOLID. It has High Cohesion and Loose Coupling, it's a good start for your next Microservice application.
Stars: ✭ 68 (-67.31%)
Mutual labels:  event-driven, solid, cqrs
Dredd
Language-agnostic HTTP API Testing Tool
Stars: ✭ 3,770 (+1712.5%)
Mutual labels:  validation, unit-testing, integration-testing
Eventflow.example
DDD+CQRS+Event-sourcing examples using EventFlow following CQRS-ES architecture. It is configured with RabbitMQ, MongoDB(Snapshot store), PostgreSQL(Read store), EventStore(GES). It's targeted to .Net Core 2.2 and include docker compose file.
Stars: ✭ 131 (-37.02%)
Mutual labels:  event-driven, dotnet-core, cqrs
Akkatecture
a cqrs and event sourcing framework for dotnet core using akka.net
Stars: ✭ 414 (+99.04%)
Mutual labels:  event-driven, dotnet-core, cqrs
Aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
Stars: ✭ 10,061 (+4737.02%)
Mutual labels:  framework, aspnet-core, dotnet-core
Booster
Booster Cloud Framework
Stars: ✭ 136 (-34.62%)
Mutual labels:  event-driven, framework, cqrs
Signalr.orleans
SignalR backend based on Orleans.
Stars: ✭ 156 (-25%)
Mutual labels:  aspnet-core, dotnet-core
100 Lines Of Code Challenge Js
Write Everything in JavaScript under 100 Lines!!!😈
Stars: ✭ 157 (-24.52%)
Mutual labels:  framework, design-patterns
Run Aspnetcore Cqrs
Real world Enterprise CRM application example of ASP.NET Core + Angular web application. Implemented CQRS Design Pattern for ASP.NET Core + Angular reference application, demonstrating a layered application architecture with DDD best practices. Download 100+ page eBook PDF from here ->
Stars: ✭ 152 (-26.92%)
Mutual labels:  aspnet-core, cqrs
Fastapi Crudrouter
A dynamic FastAPI router that automatically creates CRUD routes for your models
Stars: ✭ 159 (-23.56%)
Mutual labels:  framework, crud

DNTFrameworkCore

What is DNTFrameworkCore?

DNTFrameworkCore is a Lightweight and Extensible Infrastructure for Building High Quality Web Applications Based on ASP.NET Core and has the following goals:

  • Common structures in various applications like Cross-Cutting Concerns and etc
  • Follow DRY principle to focus on main business logic
  • Reduce the development time
  • Less bug and stop bug propagation
  • Reduce the training time of the new developer with low knowledge about OOP and OOD

Application Service

public interface IBlogService : IEntityService<int, BlogModel>
{
}

public class BlogService : EntityService<Blog, int, BlogModel>, IBlogService
{
    private readonly IMapper _mapper;

    public BlogService(
        IDbContext dbContext,
        IEventBus bus,
        IMapper mapper) : base(dbContext, bus)
    {
        _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
    }

    public override Task<IPagedResult<BlogModel>> FetchPagedListAsync(FilteredPagedRequest request,
        CancellationToken cancellationToken = default)
    {
        return EntitySet.AsNoTracking()
            .Select(b => new BlogModel
            {
                Id = b.Id,
                Version = b.Version,
                Url = b.Url,
                Title = b.Title
            }).ToPagedListAsync(request, cancellationToken);
    }

    protected override void MapToEntity(BlogModel model, Blog blog)
    {
        _mapper.Map(model, blog);
    }

    protected override BlogModel MapToModel(Blog blog)
    {
        return _mapper.Map<BlogModel>(blog);
    }
}

ASP.NET Core WebAPI

[Route("api/[controller]")]
public class BlogsController : EntityController<IBlogService, int, BlogModel>
{
    public BlogsController(IBlogService service) : base(service)
    {
    }

    protected override string CreatePermissionName => PermissionNames.Blogs_Create;
    protected override string EditPermissionName => PermissionNames.Blogs_Edit;
    protected override string ViewPermissionName => PermissionNames.Blogs_View;
    protected override string DeletePermissionName => PermissionNames.Blogs_Delete;
}

ASP.NET Core MVC

public class BlogsController : EntityController<IBlogService, int, BlogModel>
{
   public BlogsController(IBlogService service) : base(service)
   {
   }

   protected override string CreatePermissionName => PermissionNames.Blogs_Create;
   protected override string EditPermissionName => PermissionNames.Blogs_Edit;
   protected override string ViewPermissionName => PermissionNames.Blogs_View;
   protected override string DeletePermissionName => PermissionNames.Blogs_Delete;
   protected override string ViewName => "_BlogPartial";
}

_BlogPartial.cshtml

@inherits EntityFormRazorPage<BlogModel>
@{
   Layout = "_EntityFormLayout";
   EntityName = "Blog";
   DeletePermission = PermissionNames.Blogs_Delete;
   CreatePermission = PermissionNames.Blogs_Create;
   EditPermission = PermissionNames.Blogs_Edit;
   EntityDisplayName = "Blog";
}

<div class="form-group row">
   <div class="col col-md-8">
       <label asp-for="Title" class="col-form-label text-md-left"></label>
       <input asp-for="Title" autocomplete="off" class="form-control"/>
       <span asp-validation-for="Title" class="text-danger"></span>
   </div>
</div>
<div class="form-group row">
   <div class="col">
       <label asp-for="Url" class="col-form-label text-md-left"></label>
       <input asp-for="Url" class="form-control" type="url"/>
       <span asp-validation-for="Url" class="text-danger"></span>
   </div>
</div>

Role Modal MVC

Installation

To create your first project based on DNTFrameworkCore you can install the following packages:

PM> Install-Package DNTFrameworkCore
PM> Install-Package DNTFrameworkCore.EFCore
PM> Install-Package DNTFrameworkCore.EFCore.SqlServer
PM> Install-Package DNTFrameworkCore.Web
PM> Install-Package DNTFrameworkCore.Web.Tenancy
PM> Install-Package DNTFrameworkCore.Web.EFCore
PM> Install-Package DNTFrameworkCore.Licensing
PM> Install-Package DNTFrameworkCore.FluentValidation

OR

1- Run the following command to install boilerplate project template based on ASP.NET Core Web API and DNTFrameworkCore:

dotnet new --install DNTFrameworkCoreTemplateAPI::*‌‌

2- Create new project with installed template:

dotnet new dntcore-api

Now you have a solution like below that contains complete identity management feature include user,role and dynamic permission management and also integrated with persistent JWT authentication machanism:

Solution Structure

For more info about templates you can watch DNTFrameworkCoreTemplate repository

Features

  • Application Input Validation
  • Transaction Management
  • Eventing
  • EntityGraph Tracking (Master-Detail)
  • Numbering
  • Functional Programming Error Handling
  • Permission Authorization
  • EntityService
  • EntityController (API and MVC)
  • DbLogger Provider based on EFCore
  • ProtectionKey EFCore Store
  • Hooks
  • SoftDelete
  • Tenancy
  • Tracking mechanism (ICreationTracking, IModificationTracking)
  • FluentValidation Integration
  • BackgroundTaskQueue
  • RowIntegrity
  • StartupTask mechanism
  • CQRS (coming soon)
  • EntityHistory (coming soon)

Usage

DNTFrameworkCore.TestAPI Complete ASP.NET Core Web API

Create Entity

public class Task : Entity<int>, INumberedEntity, IHasRowVersion, IHasRowIntegrity, ICreationTracking, IModificationTracking
{
    public const int MaxTitleLength = 256;
    public const int MaxDescriptionLength = 1024;

    public string Title { get; set; }
    public string NormalizedTitle { get; set; }
    public string Number { get; set; }
    public string Description { get; set; }
    public TaskState State { get; set; } = TaskState.Todo;
    public byte[] Version { get; set; }
}

Implement ProjectDbContext that inherited from DbContextCore

public class ProjectDbContext : DbContextCore
{
    public ProjectDbContext(DbContextOptions<ProjectDbContext> options, IEnumerable<IHook> hooks) : base(options, hooks)
    {
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {               
        modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());

        modelBuilder.AddJsonFields();
        modelBuilder.AddTrackingFields<long>();
        modelBuilder.AddIsDeletedField();
        modelBuilder.AddRowVersionField();
        modelBuilder.AddRowIntegrityField();
            
        modelBuilder.NormalizeDateTime();
        modelBuilder.NormalizeDecimalPrecision();
            
        base.OnModelCreating(modelBuilder);
    }
}

Create Model/DTO

[LocalizationResource(Name = "SharedResource", Location = "DNTFrameworkCore.TestAPI")]
public class TaskModel : MasterModel<int>, IValidatableObject
{
    public string Title { get; set; }

    [MaxLength(50, ErrorMessage = "Validation from DataAnnotations")]
    public string Number { get; set; }

    public string Description { get; set; }
    public TaskState State { get; set; } = TaskState.Todo;

    public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
    {
        if (Title == "IValidatableObject")
        {
            yield return new ValidationResult("Validation from IValidatableObject");
        }
    }
}

Note: Based on validation infrastructure, you can validate Model/DTO with various approach, using by DataAnnotation ValidateAttribute, Implementing IValidatableObject or Implement IModelValidator that exist in DNTFrameworkCore package.

public class TaskValidator : ModelValidator<TaskModel>
{
    public override IEnumerable<ModelValidationResult> Validate(TaskModel model)
    {
        if (!Enum.IsDefined(typeof(TaskState), model.State))
        {
            yield return new ModelValidationResult(nameof(TaskModel.State), "Validation from IModelValidator");
        }
    }
}

Also in most cases, one Model/DTO can be enough for your requirements about Create/Edit/View an entity. However you can create ReadModel like below:

public class TaskReadModel : ReadModel<int>
{
    public string Title { get; set; }
    public string Number { get; set; }
    public TaskState State { get; set; } = TaskState.Todo;
}

Implement Service

public interface ITaskService : IEntityService<int, TaskReadModel, TaskModel, TaskFilteredPagedRequest>
{
}

public class TaskService : EntityService<Task, int, TaskReadModel, TaskModel, TaskFilteredPagedRequest>,
    ITaskService
{
    private readonly IMapper _mapper;
    public TaskService(IDbContext dbContext, IEventBus bus, IMapper mapper) :base(dbContext, bus)
    {
        _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper);
    }

    public override Task<IPagedResult<TaskReadModel>> FetchPagedListAsync(TaskFilteredPagedRequest request,
        CancellationToken cancellationToken = default)
    {
        return EntitySet.AsNoTracking()
            .WhereIf(model.State.HasValue, t => t.State == model.State)
            .Select(t => new TaskReadModel
            {
                Id = t.Id,
                Title = t.Title,
                State = t.State,
                Number = t.Number
            }).ToPagedListAsync(request, cancellationToken);
    }

    protected override void MapToEntity(TaskModel model, Task task)
    {
        _mapper.Map(model, task);
    }

    protected override TaskModel MapToModel(Task task)
    {
        return _mapper.Map<TaskModel>(task);
    }
}

In DNTFrameworkCore.EFCore there is no dependency to AutoMapper or other mapper libraries, then you can do mapping between Entity and Model manually by implementing MapToModel and MapToEntity abstract methods.

Implement API Controller

[Route("api/[controller]")]
public class
    TasksController : EntityController<ITaskService, int, TaskReadModel, TaskModel, TaskFilteredPagedRequest>
{
    public TasksController(ITaskService service) : base(service)
    {
    }

    protected override string CreatePermissionName => PermissionNames.Tasks_Create;
    protected override string EditPermissionName => PermissionNames.Tasks_Edit;
    protected override string ViewPermissionName => PermissionNames.Tasks_View;
    protected override string DeletePermissionName => PermissionNames.Tasks_Delete;
}
[Route("api/[controller]")]
public class BlogsController : EntityController<IBlogService, int, BlogModel>
{
    public BlogsController(IBlogService service) : base(service)
    {
    }

    protected override string CreatePermissionName => PermissionNames.Blogs_Create;
    protected override string EditPermissionName => PermissionNames.Blogs_Edit;
    protected override string ViewPermissionName => PermissionNames.Blogs_View;
    protected override string DeletePermissionName => PermissionNames.Blogs_Delete;
}

ASP.NET Boilerplate

DNTFrameworkCore vs ABP Framework

A small part of this project like the following sections are taken from ABP

  • Validation with refactoring to support functional programming error handling mechanism
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].