diff --git a/src/Templates/Commands/AddEdit/.cs.txt b/src/Templates/Commands/AddEdit/.cs.txt index 6e988ea..6460b93 100644 --- a/src/Templates/Commands/AddEdit/.cs.txt +++ b/src/Templates/Commands/AddEdit/.cs.txt @@ -7,6 +7,8 @@ namespace {namespace}; public class AddEdit{itemname}Command: ICacheInvalidatorRequest> { + [Description("Id")] + public int Id { get; set; } {dtoFieldDefinition} public string CacheKey => {itemname}CacheKey.GetAllCacheKey; @@ -16,7 +18,9 @@ public class AddEdit{itemname}Command: ICacheInvalidatorRequest> { public Mapping() { - CreateMap<{itemname}Dto, AddEdit{itemname}Command>().ReverseMap(); + CreateMap<{itemname}Dto,AddEdit{itemname}Command>(MemberList.None); + CreateMap(MemberList.None); + } } } @@ -38,7 +42,6 @@ public class AddEdit{itemname}Command: ICacheInvalidatorRequest> } public async Task> Handle(AddEdit{itemname}Command request, CancellationToken cancellationToken) { - // TODO: Implement AddEdit{itemname}CommandHandler method var dto = _mapper.Map<{itemname}Dto>(request); if (request.Id > 0) { diff --git a/src/Templates/Commands/AddEdit/.validator.cs.txt b/src/Templates/Commands/AddEdit/.validator.cs.txt index 14d25c1..74619c4 100644 --- a/src/Templates/Commands/AddEdit/.validator.cs.txt +++ b/src/Templates/Commands/AddEdit/.validator.cs.txt @@ -7,11 +7,10 @@ public class AddEdit{itemname}CommandValidator : AbstractValidator v.Name) - // .MaximumLength(256) - // .NotEmpty(); - throw new System.NotImplementedException(); + RuleFor(v => v.Name) + .MaximumLength(256) + .NotEmpty(); + } public Func>> ValidateValue => async (model, propertyName) => { diff --git a/src/Templates/Commands/Create/.cs.txt b/src/Templates/Commands/Create/.cs.txt index b2826f9..56e1262 100644 --- a/src/Templates/Commands/Create/.cs.txt +++ b/src/Templates/Commands/Create/.cs.txt @@ -8,6 +8,8 @@ namespace {namespace}; public class Create{itemname}Command: ICacheInvalidatorRequest> { + [Description("Id")] + public int Id { get; set; } {dtoFieldDefinition} public string CacheKey => {itemname}CacheKey.GetAllCacheKey; public CancellationTokenSource? SharedExpiryTokenSource => {itemname}CacheKey.SharedExpiryTokenSource(); @@ -15,7 +17,8 @@ public class Create{itemname}Command: ICacheInvalidatorRequest> { public Mapping() { - CreateMap<{itemname}Dto, Create{itemname}Command>().ReverseMap(); + CreateMap<{itemname}Dto,Create{itemname}Command>(MemberList.None); + CreateMap(MemberList.None); } } } @@ -37,7 +40,6 @@ public class Create{itemname}Command: ICacheInvalidatorRequest> } public async Task> Handle(Create{itemname}Command request, CancellationToken cancellationToken) { - // TODO: Implement Create{itemname}CommandHandler method var dto = _mapper.Map<{itemname}Dto>(request); var item = _mapper.Map<{itemname}>(dto); // raise a create domain event diff --git a/src/Templates/Commands/Create/.validator.cs.txt b/src/Templates/Commands/Create/.validator.cs.txt index 3992c8e..f191a51 100644 --- a/src/Templates/Commands/Create/.validator.cs.txt +++ b/src/Templates/Commands/Create/.validator.cs.txt @@ -7,11 +7,11 @@ namespace {namespace}; { public Create{itemname}CommandValidator() { - // TODO: Implement Create{itemname}CommandValidator method, for example: - // RuleFor(v => v.Name) - // .MaximumLength(256) - // .NotEmpty(); - throw new System.NotImplementedException(); + + RuleFor(v => v.Name) + .MaximumLength(256) + .NotEmpty(); + } public Func>> ValidateValue => async (model, propertyName) => { diff --git a/src/Templates/Commands/Delete/.cs.txt b/src/Templates/Commands/Delete/.cs.txt index f5a97e8..a2df2d8 100644 --- a/src/Templates/Commands/Delete/.cs.txt +++ b/src/Templates/Commands/Delete/.cs.txt @@ -36,7 +36,6 @@ namespace {namespace}; } public async Task> Handle(Delete{itemname}Command request, CancellationToken cancellationToken) { - // TODO: Implement DeleteChecked{nameofPlural}CommandHandler method var items = await _context.{nameofPlural}.Where(x=>request.Id.Contains(x.Id)).ToListAsync(cancellationToken); foreach (var item in items) { diff --git a/src/Templates/Commands/Delete/.validator.cs.txt b/src/Templates/Commands/Delete/.validator.cs.txt index bf3fc90..feb3c60 100644 --- a/src/Templates/Commands/Delete/.validator.cs.txt +++ b/src/Templates/Commands/Delete/.validator.cs.txt @@ -7,9 +7,9 @@ public class Delete{itemname}CommandValidator : AbstractValidator v.Id).NotNull().ForEach(v=>v.GreaterThan(0)); - throw new System.NotImplementedException(); + + RuleFor(v => v.Id).NotNull().ForEach(v=>v.GreaterThan(0)); + } } diff --git a/src/Templates/Commands/Import/.cs.txt b/src/Templates/Commands/Import/.cs.txt index cefdd99..f706d20 100644 --- a/src/Templates/Commands/Import/.cs.txt +++ b/src/Templates/Commands/Import/.cs.txt @@ -48,10 +48,9 @@ namespace {namespace}; #nullable disable warnings public async Task> Handle(Import{nameofPlural}Command request, CancellationToken cancellationToken) { - // TODO: Implement Import{nameofPlural}CommandHandler method + var result = await _excelService.ImportAsync(request.Data, mappers: new Dictionary> { - // TODO: Define the fields that should be read from Excel, for example: {importFuncExpression} }, _localizer[_dto.GetClassDescription()]); if (result.Succeeded && result.Data is not null) diff --git a/src/Templates/Commands/Import/.validator.cs.txt b/src/Templates/Commands/Import/.validator.cs.txt index 8725317..ebdaaa5 100644 --- a/src/Templates/Commands/Import/.validator.cs.txt +++ b/src/Templates/Commands/Import/.validator.cs.txt @@ -7,11 +7,11 @@ namespace {namespace}; { public Import{nameofPlural}CommandValidator() { - // TODO: Implement Import{itemname}CommandValidator method, for example: - // RuleFor(v => v.Data) - // .NotNull() - // .NotEmpty(); - throw new System.NotImplementedException(); + + RuleFor(v => v.Data) + .NotNull() + .NotEmpty(); + } } diff --git a/src/Templates/Commands/Update/.cs.txt b/src/Templates/Commands/Update/.cs.txt index 1a53f11..05be97c 100644 --- a/src/Templates/Commands/Update/.cs.txt +++ b/src/Templates/Commands/Update/.cs.txt @@ -8,6 +8,8 @@ namespace {namespace}; public class Update{itemname}Command: ICacheInvalidatorRequest> { + [Description("Id")] + public int Id { get; set; } {dtoFieldDefinition} public string CacheKey => {itemname}CacheKey.GetAllCacheKey; public CancellationTokenSource? SharedExpiryTokenSource => {itemname}CacheKey.SharedExpiryTokenSource(); @@ -15,7 +17,8 @@ public class Update{itemname}Command: ICacheInvalidatorRequest> { public Mapping() { - CreateMap<{itemname}Dto, Update{itemname}Command>().ReverseMap(); + CreateMap<{itemname}Dto,Update{itemname}Command>(MemberList.None); + CreateMap(MemberList.None); } } } diff --git a/src/Templates/Commands/Update/.validator.cs.txt b/src/Templates/Commands/Update/.validator.cs.txt index c3a5570..70a3b7c 100644 --- a/src/Templates/Commands/Update/.validator.cs.txt +++ b/src/Templates/Commands/Update/.validator.cs.txt @@ -7,11 +7,9 @@ public class Update{itemname}CommandValidator : AbstractValidator v.Name) - // .MaximumLength(256) - // .NotEmpty(); - throw new System.NotImplementedException(); + RuleFor(v => v.Id).NotNull(); + RuleFor(v => v.Name).MaximumLength(256).NotEmpty(); + } public Func>> ValidateValue => async (model, propertyName) => { diff --git a/src/Templates/DTOs/.dto.cs.txt b/src/Templates/DTOs/.dto.cs.txt index d316189..5c1c727 100644 --- a/src/Templates/DTOs/.dto.cs.txt +++ b/src/Templates/DTOs/.dto.cs.txt @@ -7,7 +7,8 @@ namespace {namespace}; [Description("{nameofPlural}")] public class {itemname}Dto { - // TODO: define data transfer object (DTO) fields, for example: + [Description("Id")] + public int Id { get; set; } {dtoFieldDefinition} private class Mapping : Profile diff --git a/src/Templates/Queries/Export/.cs.txt b/src/Templates/Queries/Export/.cs.txt index 2b3da06..35fdef4 100644 --- a/src/Templates/Queries/Export/.cs.txt +++ b/src/Templates/Queries/Export/.cs.txt @@ -9,10 +9,6 @@ namespace {namespace}; public class Export{nameofPlural}Query : {itemname}AdvancedFilter, IRequest> { - public string OrderBy { get; set; } = "Id"; - public string SortDirection { get; set; } = "Descending"; - public {itemname}ListView ListView { get; set; } = {itemname}ListView.All; - public UserProfile? CurrentUser { get; set; } public {itemname}AdvancedSpecification Specification => new {itemname}AdvancedSpecification(this); } @@ -39,7 +35,6 @@ public class Export{nameofPlural}QueryHandler : #nullable disable warnings public async Task> Handle(Export{nameofPlural}Query request, CancellationToken cancellationToken) { - // TODO: Implement Export{nameofPlural}QueryHandler method var data = await _context.{nameofPlural}.ApplySpecification(request.Specification) .OrderBy($"{request.OrderBy} {request.SortDirection}") .ProjectTo<{itemname}Dto>(_mapper.ConfigurationProvider) diff --git a/src/Templates/Queries/GetAll/.cs.txt b/src/Templates/Queries/GetAll/.cs.txt index 81b0efd..82e2f3e 100644 --- a/src/Templates/Queries/GetAll/.cs.txt +++ b/src/Templates/Queries/GetAll/.cs.txt @@ -32,7 +32,6 @@ public class GetAll{nameofPlural}QueryHandler : public async Task> Handle(GetAll{nameofPlural}Query request, CancellationToken cancellationToken) { - // TODO: Implement GetAll{nameofPlural}QueryHandler method var data = await _context.{nameofPlural} .ProjectTo<{itemname}Dto>(_mapper.ConfigurationProvider) .AsNoTracking() diff --git a/src/Templates/Queries/GetById/.cs.txt b/src/Templates/Queries/GetById/.cs.txt index b037d96..b0ca636 100644 --- a/src/Templates/Queries/GetById/.cs.txt +++ b/src/Templates/Queries/GetById/.cs.txt @@ -34,7 +34,6 @@ public class Get{itemname}ByIdQueryHandler : public async Task<{itemname}Dto> Handle(Get{itemname}ByIdQuery request, CancellationToken cancellationToken) { - // TODO: Implement Get{itemname}ByIdQueryHandler method var data = await _context.{nameofPlural}.ApplySpecification(new {itemname}ByIdSpecification(request.Id)) .ProjectTo<{itemname}Dto>(_mapper.ConfigurationProvider) .FirstAsync(cancellationToken) ?? throw new NotFoundException($"{itemname} with id: [{request.Id}] not found.");; diff --git a/src/Templates/Queries/Pagination/.cs.txt b/src/Templates/Queries/Pagination/.cs.txt index 29ce71f..7baf3a4 100644 --- a/src/Templates/Queries/Pagination/.cs.txt +++ b/src/Templates/Queries/Pagination/.cs.txt @@ -38,7 +38,6 @@ public class {nameofPlural}WithPaginationQueryHandler : public async Task> Handle({nameofPlural}WithPaginationQuery request, CancellationToken cancellationToken) { - // TODO: Implement {nameofPlural}WithPaginationQueryHandler method var data = await _context.{nameofPlural}.OrderBy($"{request.OrderBy} {request.SortDirection}") .ProjectToPaginatedDataAsync<{itemname}, {itemname}Dto>(request.Specification, request.PageNumber, request.PageSize, _mapper.ConfigurationProvider, cancellationToken); return data;