Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor #10

Merged
merged 4 commits into from
Nov 12, 2022
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
15 changes: 13 additions & 2 deletions src/Templatemap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private static string splitCamelCase(string str)
private static string createDtoFieldDefinition(IntellisenseObject classObject)
{
var output = new StringBuilder();
foreach(var property in classObject.Properties.Where(x=>x.Type.IsKnownType==true))
foreach(var property in classObject.Properties.Where(x => x.Type.IsKnownType == true))
{
output.Append($" [Description(\"{splitCamelCase(property.Name)}\")]\r\n");
if (property.Name == PRIMARYKEY)
Expand All @@ -207,15 +207,26 @@ private static string createDtoFieldDefinition(IntellisenseObject classObject)
case "string" when property.Name.Equals("Name", StringComparison.OrdinalIgnoreCase):
output.Append($" public {property.Type.CodeName} {property.Name} {{get;set;}} = String.Empty; \r\n");
break;
case "string" when !property.Name.Equals("Name", StringComparison.OrdinalIgnoreCase):
case "string" when !property.Name.Equals("Name", StringComparison.OrdinalIgnoreCase) && !property.Type.IsArray && !property.Type.IsDictionary:
output.Append($" public {property.Type.CodeName}? {property.Name} {{get;set;}} \r\n");
break;
case "string" when !property.Name.Equals("Name", StringComparison.OrdinalIgnoreCase) && property.Type.IsArray:
output.Append($" public HashSet<{property.Type.CodeName}>? {property.Name} {{get;set;}} \r\n");
break;
case "System.DateTime?":
output.Append($" public DateTime? {property.Name} {{get;set;}} \r\n");
break;
case "System.DateTime":
output.Append($" public DateTime {property.Name} {{get;set;}} \r\n");
break;
case "decimal?":
case "decimal":
case "int?":
case "int":
case "double?":
case "double":
output.Append($" public {property.Type.CodeName} {property.Name} {{get;set;}} \r\n");
break;
default:
if (property.Type.CodeName.Any(x => x == '?'))
{
Expand Down
13 changes: 9 additions & 4 deletions src/Templates/Pages/.formdialog.razor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@

async Task Submit()
{
if(_form is not null) {
await _form.Validate();
if (_form.IsValid)
{
await _form!.Validate();
if (_form!.IsValid)
{
MudDialog.Close(DialogResult.Ok(true));
}
else
{
foreach(var err in _form.Errors){
Snackbar.Add($"{err}", MudBlazor.Severity.Error);
}
}

}
void Cancel() => MudDialog.Cancel();
}
4 changes: 2 additions & 2 deletions src/Templates/Pages/.razor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<ColGroup>
<MudHidden Breakpoint="Breakpoint.SmAndDown">
<col style="width:50px;" />
<col style="width:100px;" />
<col style="width:120px;" />
<col />
</MudHidden>
</ColGroup>
Expand Down Expand Up @@ -203,7 +203,7 @@
private bool _uploading;
private bool _downloading;
[Inject]
private ISender _mediator { get; set; } = default!;
private IMediator _mediator { get; set; } = default!;
[Inject]
private IMapper _mapper { get; set; } = default!;
[CascadingParameter]
Expand Down