Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Templatemap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ private static string createMudTdDefinition(string name,IntellisenseObject class
output.Append(" ");
if (property.Type.CodeName.StartsWith("bool", StringComparison.OrdinalIgnoreCase))
{
output.Append($" <MudTd HideSmall=\"false\" DataLabel=\"@L[_{name.ToLower()}Dto.GetMemberDescription(x=>x.{property.Name})]\" ><MudCheckBox Checked=\"@context.{property.Name}\" ReadOnly></MudCheckBox></MudTd> \r\n");
output.Append($" <MudTd HideSmall=\"false\" DataLabel=\"@L[_{name.ToLower()}Dto.GetMemberDescription(x=>x.{property.Name})]\" ><MudCheckBox Value=\"@context.{property.Name}\" ReadOnly></MudCheckBox></MudTd> \r\n");
}
else if (property.Type.CodeName.Equals("System.DateTime", StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -678,7 +678,7 @@ private static string createMudFormFieldDefinition(IntellisenseObject classObjec
case "bool":
output.Append($"<MudItem xs=\"12\" md=\"6\"> \r\n");
output.Append(" ");
output.Append($" <MudCheckBox Label=\"@L[_model.GetMemberDescription(x=>x.{property.Name})]\" @bind-Checked=\"_model.{property.Name}\" For=\"@(() => _model.{property.Name})\" ></MudCheckBox>\r\n");
output.Append($" <MudCheckBox Label=\"@L[_model.GetMemberDescription(x=>x.{property.Name})]\" @bind-Value=\"_model.{property.Name}\" For=\"@(() => _model.{property.Name})\" ></MudCheckBox>\r\n");
output.Append(" ");
output.Append($"</MudItem> \r\n");
break;
Expand Down
2 changes: 2 additions & 0 deletions src/Templates/Caching/.cachekey.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// mechanism to refresh cached data in a thread-safe manner.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
#nullable disable warnings

namespace {namespace};
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Templates/Commands/AddEdit/.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// Documentation: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------

// Usage: Use this command to add or edit a {itemnamelowercase}. Caching and domain event handling are automatic.
#nullable enable
#nullable disable warnings


using {selectns}.{nameofPlural}.Caching;
Expand Down
5 changes: 2 additions & 3 deletions src/Templates/Commands/AddEdit/.validator.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------

// Usage:
// Validates AddEdit{itemname}Command constraints (e.g., maximum field lengths).
#nullable enable
#nullable disable warnings


namespace {namespace};
Expand Down
6 changes: 2 additions & 4 deletions src/Templates/Commands/Create/.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------

// Usage:
// Use this command to create a new {itemnamelowercase} with required fields and automatic domain event handling.

#nullable enable
#nullable disable warnings

using {selectns}.{nameofPlural}.Caching;

Expand Down
6 changes: 2 additions & 4 deletions src/Templates/Commands/Create/.validator.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------

// Usage:
// Validates Create{itemname}Command ensuring constraints (e.g., non-empty Name field) before execution.

#nullable enable
#nullable disable warnings

namespace {namespace};

Expand Down
18 changes: 7 additions & 11 deletions src/Templates/Commands/Delete/.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------

// Usage:
// Delete multiple {nameofPlural} by specifying their IDs.
// Domain events are raised for each deletion to support cache invalidation.

#nullable enable
#nullable disable warnings

using {selectns}.{nameofPlural}.Caching;


namespace {namespace};

public class Delete{itemname}Command: ICacheInvalidatorRequest<Result<int>>
public class Delete{itemname}Command: ICacheInvalidatorRequest<Result>
{
public int[] Id { get; }
public string CacheKey => {itemname}CacheKey.GetAllCacheKey;
Expand All @@ -31,7 +27,7 @@ public class Delete{itemname}Command: ICacheInvalidatorRequest<Result<int>>
}

public class Delete{itemname}CommandHandler :
IRequestHandler<Delete{itemname}Command, Result<int>>
IRequestHandler<Delete{itemname}Command, Result>

{
private readonly IApplicationDbContext _context;
Expand All @@ -40,7 +36,7 @@ public class Delete{itemname}CommandHandler :
{
_context = context;
}
public async Task<Result<int>> Handle(Delete{itemname}Command request, CancellationToken cancellationToken)
public async Task<Result> Handle(Delete{itemname}Command request, CancellationToken cancellationToken)
{
var items = await _context.{nameofPlural}.Where(x=>request.Id.Contains(x.Id)).ToListAsync(cancellationToken);
foreach (var item in items)
Expand All @@ -49,8 +45,8 @@ public class Delete{itemname}CommandHandler :
item.AddDomainEvent(new {itemname}DeletedEvent(item));
_context.{nameofPlural}.Remove(item);
}
var result = await _context.SaveChangesAsync(cancellationToken);
return await Result<int>.SuccessAsync(result);
await _context.SaveChangesAsync(cancellationToken);
return await Result.SuccessAsync();
}

}
Expand Down
6 changes: 2 additions & 4 deletions src/Templates/Commands/Delete/.validator.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------

// Usage:
// Validates Delete{itemname}Command by checking that the ID list is non-null and all IDs are > 0.

#nullable enable
#nullable disable warnings

namespace {namespace};

Expand Down
7 changes: 2 additions & 5 deletions src/Templates/Commands/Import/.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------
//
// Usage:
// - Use `Import{itemname}sCommand` to import {itemnamelowercase}s from Excel.
// - Use `Create{itemname}sTemplateCommand` to generate an Excel template for {itemnamelowercase} data.

#nullable enable
#nullable disable warnings

using {selectns}.{nameofPlural}.DTOs;
using {selectns}.{nameofPlural}.Caching;
Expand Down
6 changes: 2 additions & 4 deletions src/Templates/Commands/Import/.validator.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------
//
// Usage:
// Validates Import{itemname}sCommand to ensure valid data before import.

#nullable enable
#nullable disable warnings

namespace {namespace};

Expand Down
5 changes: 2 additions & 3 deletions src/Templates/Commands/Update/.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------
//
// Usage:
// Use Update{itemname}Command to update an existing {itemnamelowercase}. If found, changes are applied, cache is invalidated, and {itemname}UpdatedEvent is raised.
#nullable enable
#nullable disable warnings

using {selectns}.{nameofPlural}.DTOs;
using {selectns}.{nameofPlural}.Caching;
Expand Down
6 changes: 2 additions & 4 deletions src/Templates/Commands/Update/.validator.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------
//
// Usage:
// Validates Update{itemname}Command to ensure complete and valid data before processing the update.

#nullable enable
#nullable disable warnings

namespace {namespace};

Expand Down
5 changes: 2 additions & 3 deletions src/Templates/DTOs/.dto.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
// Docs: https://docs.cleanarchitectureblazor.com/features/{itemnamelowercase}
// </auto-generated>
//------------------------------------------------------------------------------
//
// Usage:
// Use {itemname}Dto to represent {itemnamelowercase} data across commands, queries, and views.
#nullable enable
#nullable disable warnings


namespace {namespace};
Expand Down
15 changes: 8 additions & 7 deletions src/Templates/Pages/.create.razor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@
public string? Title { get; private set; }
MudForm? _{itemnamelowercase}Form;
private bool _saving = false;
private List<BreadcrumbItem> _breadcrumbItems = new List<BreadcrumbItem>
{
new BreadcrumbItem("Home", href: "/"),
new BreadcrumbItem("{nameofPlural}", href: "/pages/{nameofplurallowercase}"),
new BreadcrumbItem("Create {itemname}", href:null, disabled:true)
};
private List<BreadcrumbItem>? _breadcrumbItems;
private Create{itemname}Command _model = new();
protected override Task OnInitializedAsync()
{
Title = L["Create {itemname}"];
Title = L["New {itemname}"];
_breadcrumbItems = new List<BreadcrumbItem>
{
new BreadcrumbItem(L["Home"], href: "/"),
new BreadcrumbItem(L["{nameofPlural}"], href: "/pages/{nameofplurallowercase}"),
new BreadcrumbItem(L["Create {itemname}"], href:null, disabled:true)
};
return Task.CompletedTask;
}
async Task OnSubmit()
Expand Down
11 changes: 6 additions & 5 deletions src/Templates/Pages/.edit.razor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@
public int Id { get; set; }
MudForm? _{itemnamelowercase}Form;
private bool _saving = false;
private List<BreadcrumbItem> _breadcrumbItems = new List<BreadcrumbItem>
{
new BreadcrumbItem("Home", href: "/"),
new BreadcrumbItem("{nameofPlural}", href: "/pages/{nameofplurallowercase}")
};
private List<BreadcrumbItem>? _breadcrumbItems;
private Update{itemname}Command? _model;
protected override async Task OnInitializedAsync()
{
Title = L["Edit {itemname}"];
_breadcrumbItems = new List<BreadcrumbItem>
{
new BreadcrumbItem(L["Home"], href: "/"),
new BreadcrumbItem(L["{nameofPlural}"], href: "/pages/{nameofplurallowercase}")
};
var result = await Mediator.Send(new Get{itemname}ByIdQuery() { Id = Id });
result.Map(data =>
{
Expand Down
11 changes: 6 additions & 5 deletions src/Templates/Pages/.view.razor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@
public string? Title { get; private set; }
[Parameter]
public int Id { get; set; }
private List<BreadcrumbItem> _breadcrumbItems = new List<BreadcrumbItem>
{
new BreadcrumbItem("Home", href: "/"),
new BreadcrumbItem("{nameofPlural}", href: "/pages/{nameofplurallowercase}")
};
private List<BreadcrumbItem>? _breadcrumbItems;
private {itemname}Dto? _model;
protected override async Task OnInitializedAsync()
{
Title = L["{itemname}"];
_breadcrumbItems = new List<BreadcrumbItem>
{
new BreadcrumbItem(L["Home"], href: "/"),
new BreadcrumbItem(L["{nameofPlural}"], href: "/pages/{nameofplurallowercase}")
};
var result = await Mediator.Send(new Get{itemname}ByIdQuery() { Id = Id });
result.Map(data =>
{
Expand Down
2 changes: 2 additions & 0 deletions src/Templates/Queries/Export/.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// the specified {itemnamelowercase} details.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
#nullable disable warnings

using {selectns}.{nameofPlural}.DTOs;
using {selectns}.{nameofPlural}.Caching;
Expand Down
2 changes: 2 additions & 0 deletions src/Templates/Queries/GetAll/.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// queries.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
#nullable disable warnings

using {selectns}.{nameofPlural}.DTOs;
using {selectns}.{nameofPlural}.Caching;
Expand Down
2 changes: 2 additions & 0 deletions src/Templates/Queries/GetById/.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// to optimize performance for repeated retrievals of the same {itemnamelowercase}.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
#nullable disable warnings

using {selectns}.{nameofPlural}.DTOs;
using {selectns}.{nameofPlural}.Caching;
Expand Down
2 changes: 2 additions & 0 deletions src/Templates/Queries/Pagination/.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// options. The result is cached to enhance performance for repeated queries.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
#nullable disable warnings

using {selectns}.{nameofPlural}.DTOs;
using {selectns}.{nameofPlural}.Caching;
Expand Down
2 changes: 2 additions & 0 deletions src/Templates/Specifications/AdvancedFilter.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// filters such as view types and user-specific filters.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
#nullable disable warnings

namespace {namespace};

Expand Down
2 changes: 2 additions & 0 deletions src/Templates/Specifications/AdvancedSpecification.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// {itemname} entity, supporting different views and keyword-based searches.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
#nullable disable warnings

namespace {namespace};
#nullable disable warnings
Expand Down
2 changes: 2 additions & 0 deletions src/Templates/Specifications/ByIdSpecification.cs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// Defines a specification for filtering a {itemname} entity by its ID.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
#nullable disable warnings

namespace {namespace};
#nullable disable warnings
Expand Down
Loading