DDD.Helper
1.0.1
See the version list below for details.
dotnet add package DDD.Helper --version 1.0.1
NuGet\Install-Package DDD.Helper -Version 1.0.1
<PackageReference Include="DDD.Helper" Version="1.0.1" />
paket add DDD.Helper --version 1.0.1
#r "nuget: DDD.Helper, 1.0.1"
// Install DDD.Helper as a Cake Addin
#addin nuget:?package=DDD.Helper&version=1.0.1
// Install DDD.Helper as a Cake Tool
#tool nuget:?package=DDD.Helper&version=1.0.1
DDD.Helper
Aplication Tier
Use Automapper:
Constructor
public ExampleEntityAppService(IServiceProvider serviceProvider)
: base(serviceProvider)
{
}
Method
// Inside method ...
var entity = _mapper.Map<Entity>(dto) //add
// or
var entity = _mapper.Map(dto, entity) //update
...
Use Response Services to Controller
Global return JsonResult from Controller
{
"Valid":"true",
"Message": "any message",
"Detail": "",
"Data": null
}
API Tier - Controller
public async Task<IActionResult> ExampleMethodController() =>
new OkObjectResult(await _anyAppService.ExampleString());
Application Tier - AppService Layer
public Task<JsonResult<string>> ExampleString()
{
return new JsonResult<string>("HelloWord")
}
public Task<JsonResult<EntityDto>> ExampleEntityDto()
{
var value = new EntityDto(); // Do anything
return new JsonResult<EntityDto>(value)
}
public Task<JsonResult<EntityDto>> ExampleEntityDtoWithValidations()
{
var value = new EntityDto(); // Do anything
var validations = _anyService.ValidateEntityAsync(value, new EntityDtoValidator(_serviceProvider))
return new JsonResult<EntityDto>(validations, value)
}
Domain Tier
Entity
Set default PrimaryKey to Entity
default key name is [Id] use [:Entity<YourIdType>] Note: If your key is difirent then use EntityConfig in Infraestrucure Tier
public class EntityExample: Entity<int>
{
}
Set Status to Entity
default name status is [Status] required enumerable type
public class EntityExample: Entity<int, ExampleStatus>
{
}
public enum ExampleStatus
{
Active = 0,
Inactive = 1,
}
Entry - COREBIT
Return default Entry from procedure Oracle
Enumerable [ResultMode]
public enum ResultMode
{
Error = 0,
Success = 1,
Warning = 2
}
Entity [EntryResult]
public ResultMode Estado { get; set; }
public string Mensaje { get; set; }
Output default [CUR_Listar]
public class EntryExample
{
...
//any other default params
private object Something { get; } // <== return CURSOR
private int SomethingInt { get; } // <== return number
private string SomethingString { get; } // <== return VARCHAR2
... Others
}
Service
use default methods process
CRUD
Task<TEntity> GetAsync(TId id, include = null);
IQueryable<TEntity> All(bool @readonly = true);
IQueryable<TEntity> Find(predicate, include = null, bool @readonly = true);
Task<int> CountAsync(predicate);
Task<ValidationResult> AddAsync(TEntity entity, params IValidator<TEntity>[] validaciones);
Task<ValidationResult> AddAsync(TEntity entity, IValidator<TEntity> validation);
Task<ValidationResult> UpdateAsync(TEntity entity, params IValidator<TEntity>[] validaciones);
Task<ValidationResult> UpdateAsync(TEntity entity, IValidator<TEntity> validation);
Task<ValidationResult> DeleteAsync(TEntity entity, params IValidator<TEntity>[] validaciones);
Task<ValidationResult> DeleteAsync(TEntity entity, IValidator<TEntity> validation);
Task<ValidationResult> AddRangeAsync(IEnumerable<TEntity> entities, params IValidator<TEntity>[] validaciones);
Task<ValidationResult> AddRangeAsync(IEnumerable<TEntity> entities, IValidator<TEntity> validation);
Validated
Task<ValidationResult> ValidateEntityAsync<TNewEntity>(TNewEntity entity, IValidator<TNewEntity> validation);
Task<ValidationResult> ValidateEntityAsync<TNewEntity>(TNewEntity entity, IEnumerable<IValidator<TNewEntity>> validations);
Task<ValidationResult> ValidateEntryResultAsync(EntryResult result);
use service example
Domain Tier - implement [Interface Service]
public interface IEntityExampleService : IService<ExampleEntity,int[AnyOtherType]>
{
// any customers methods
}
Domain Tier - implement [Class Service]
public class EntityExampleService : Service<ExampleEntity,int[AnyOtherType]>, IEntityExampleService
{
// any customers methods
}
Application Tier - use [Class AppService]
public ExampleEntityAppService(IExampleEntityService exampleEntityService)
{
_exampleEntityService = exampleEntityService;
}
...
// in implemented methods
_exampleEntityService.Find(.......
_exampleEntityService.AddAsync(.......
_exampleEntityService.UpdateAsync(.......
_exampleEntityService.others....
...
Validations
Implement Entity Validations class Note: Review documentation:
public class ExampleEntityValidator : BaseValidator<ExampleEntity>
{
public ExampleEntityValidator(IServiceProvider serviceProvider)
: base(serviceProvider)
{
RuleFor(p => p)
...
}
}
// methods for validations
Use Entity Validations class Note: in Application tier, class AppService
// inside methods
_exampleEntityService.AddAsync(entity, new ExampleEntityValidator(serviceProvider));
_exampleEntityService.anyothers...(entity, new ExampleEntityValidator(serviceProvider));
https://medium.com/@er.bharat1992/writing-readme-md-markdown-file-file-bd711d1afbfa
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- AutoMapper.Extensions.Microsoft.DependencyInjection (>= 8.1.0)
- Dapper (>= 2.0.78)
- FluentValidation.AspNetCore (>= 9.3.0)
- Oracle.EntityFrameworkCore (>= 3.19.80)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.4.5 | 437 | 9/9/2022 |
1.0.4.2 | 398 | 9/7/2022 |
1.0.4.1 | 425 | 5/27/2022 |
1.0.4 | 401 | 5/27/2022 |
1.0.3.1 | 516 | 5/16/2022 |
1.0.3 | 535 | 3/29/2022 |
1.0.2.2 | 402 | 10/25/2021 |
1.0.2.1 | 742 | 3/8/2021 |
1.0.1.7 | 527 | 3/3/2021 |
1.0.1.6 | 381 | 3/1/2021 |
1.0.1.5 | 393 | 12/22/2020 |
1.0.1 | 393 | 11/23/2020 |
1.0.0.9 | 431 | 11/21/2020 |
1.0.0.1 | 404 | 11/19/2020 |