Skip to content

Commit b720251

Browse files
🎨 update packutils and add pipeliner extension
1 parent 3ce1e2f commit b720251

14 files changed

+632
-174
lines changed

AspNetScaffolding3.DemoApi/AspNetScaffolding3.DemoApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="PackUtils" Version="1.0.65" />
8+
<PackageReference Include="PackUtils" Version="1.0.66" />
99
</ItemGroup>
1010

1111
<ItemGroup>

AspNetScaffolding3/AspNetScaffolding3.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<ItemGroup>
1919
<PackageReference Include="AspNetCore.HealthChecks.AzureStorage" Version="3.0.1" />
2020
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="3.0.1" />
21-
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="3.0.4" />
21+
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="3.0.5" />
2222
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="3.0.0" />
2323
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="3.0.0" />
2424
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.0.0" />
@@ -33,9 +33,9 @@
3333
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.1" />
3434
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
3535
<PackageReference Include="Mongo.CRUD" Version="1.0.13" />
36-
<PackageReference Include="PackUtils" Version="1.0.65" />
36+
<PackageReference Include="PackUtils" Version="1.0.66" />
3737
<PackageReference Include="PagedList.NetCore" Version="1.0.6" />
38-
<PackageReference Include="PipelineR" Version="1.0.25" />
38+
<PackageReference Include="PipelineR" Version="1.0.29" />
3939
<PackageReference Include="RestSharp.Easy" Version="1.0.14" />
4040
<PackageReference Include="RestSharp.Serilog.Auto" Version="1.0.44" />
4141
<PackageReference Include="Serilog.Builder" Version="1.0.25" />

AspNetScaffolding3/Models/ApiSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public string GetPathPrefixConsideringVersion()
3838

3939
public JsonSerializerEnum JsonSerializer { get; set; }
4040

41+
public string JsonSerializerString => Api.ApiSettings.JsonSerializer.ToString().ToLower();
42+
4143
public string[] SupportedCultures { get; set; }
4244

4345
public string RequestKeyProperty { get; set; }
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using AspNetScaffolding;
2+
using Microsoft.AspNetCore.Mvc;
3+
using PackUtils;
4+
using PipelineR;
5+
using System.Linq;
6+
using WebApi.Models.Response;
7+
8+
namespace AspNetScaffolding3.Utilities
9+
{
10+
public static class PipelineRExtension
11+
{
12+
public static IActionResult AsActionResult(this RequestHandlerResult requestHandlerResult)
13+
{
14+
var responseObject = requestHandlerResult.Result();
15+
16+
if (requestHandlerResult.Errors != null)
17+
{
18+
var errorsResponse = new ErrorsResponse();
19+
20+
foreach (var error in requestHandlerResult.Errors)
21+
{
22+
string property = null;
23+
24+
if (error.Property != null)
25+
{
26+
var parts = error.Property.Split(".").ToList();
27+
28+
if (parts.Count > 1)
29+
{
30+
parts.RemoveAt(0);
31+
}
32+
33+
var finalParts = parts.Select(i => i.ToCase(Api.ApiSettings.JsonSerializerString));
34+
property = string.Join(".", finalParts);
35+
}
36+
37+
errorsResponse.AddError(error.Message, property);
38+
}
39+
40+
responseObject = errorsResponse;
41+
}
42+
43+
return new ObjectResult(responseObject)
44+
{
45+
StatusCode = requestHandlerResult.StatusCode
46+
};
47+
}
48+
}
49+
}
Binary file not shown.

Template/src/AspNetScaffoldingTemplate/AspNetScaffoldingAdditionalData.Designer.cs

Lines changed: 144 additions & 136 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Template/src/AspNetScaffoldingTemplate/AspNetScaffoldingAdditionalData.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ public AspNetScaffoldingAdditionalData()
3737
{ "version", false }
3838
};
3939

40-
AddPlaceholder("Thiago Barradas", this.authorNameTxt);
41-
AddPlaceholder("[email protected]", this.authorEmailTxt);
42-
AddPlaceholder("MyCompanyName", this.companyTxt);
43-
AddPlaceholder("MyTeamName", this.teamTxt);
44-
AddPlaceholder("path-prefix", this.pathTxt);
45-
AddPlaceholder("1", this.versionTxt, true);
40+
41+
this.backBtn.TabIndex = 6;
42+
this.doneBtn.TabIndex = 7;
43+
44+
AddPlaceholder("[email protected]", this.authorEmailTxt, 5);
45+
AddPlaceholder("Thiago Barradas", this.authorNameTxt, 4);
46+
AddPlaceholder("1", this.versionTxt, 3, true);
47+
AddPlaceholder("path-prefix", this.pathTxt, 2);
48+
AddPlaceholder("MyTeamName", this.teamTxt, 1);
49+
AddPlaceholder("MyCompanyName", this.companyTxt, 0);
4650
}
4751

4852
private void doneBtn_Click(object sender, System.EventArgs e)
@@ -155,13 +159,14 @@ private void CheckError()
155159
}
156160
}
157161

158-
private void AddPlaceholder(string placeholder, TextBox txtBox, bool ignoreReturn = false)
162+
private void AddPlaceholder(string placeholder, TextBox txtBox, int tabIndex, bool ignoreReturn = false)
159163
{
160164
txtBox.GotFocus += (s, e) => { this.PlaceholderGotFocus(placeholder, txtBox, ignoreReturn); };
161165
txtBox.LostFocus += (s, e) => { this.PlaceholderLostFocus(placeholder, txtBox, ignoreReturn); };
162166
txtBox.TextChanged += (s, e) => { this.PlaceholderTextChanged(placeholder, txtBox, ignoreReturn); };
163167
txtBox.Text = placeholder;
164168
txtBox.ForeColor = Color.FromArgb(200, 200, 200);
169+
txtBox.TabIndex = tabIndex;
165170
}
166171

167172
private void PlaceholderGotFocus(string placeholder, TextBox txtBox, bool ignoreReturn)
@@ -204,7 +209,7 @@ private void PlaceholderTextChanged(string placeholder, TextBox txtBox, bool ign
204209

205210
if (txtBox.Text.Trim() == placeholder)
206211
{
207-
txtBox.ForeColor = Color.FromArgb(30, 30, 30);
212+
txtBox.ForeColor = Color.FromArgb(200, 200, 200);
208213
}
209214
else
210215
{

0 commit comments

Comments
 (0)