Skip to content

Commit 5f9db59

Browse files
authored
Merge pull request #93 from tghamm/develop
.NET 6 Example Project, New CI
2 parents fec60e0 + c380e3c commit 5f9db59

File tree

170 files changed

+74050
-50738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+74050
-50738
lines changed
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.24720.0
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.2.32630.192
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.DynamicLinqQueryBuilder", "Castle.DynamicLinqQueryBuilder\Castle.DynamicLinqQueryBuilder.csproj", "{C73EA60C-7046-4665-8A79-0E2AA85C43EC}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Castle.DynamicLinqQueryBuilder", "Castle.DynamicLinqQueryBuilder\Castle.DynamicLinqQueryBuilder.csproj", "{C73EA60C-7046-4665-8A79-0E2AA85C43EC}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Castle.DynamicLinqQueryBuilder.Samples", "Castle.DynamicLinqQueryBuilder.Samples\Castle.DynamicLinqQueryBuilder.Samples.csproj", "{0C128A21-F05D-4966-8EC6-F9292A259AA2}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Castle.DynamicLinqQueryBuilder.Example", "Castle.DynamicLinqQueryBuilder.Example\Castle.DynamicLinqQueryBuilder.Example.csproj", "{E126F465-CD99-4DE3-8AED-2098C2B96DA6}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,12 +17,15 @@ Global
1717
{C73EA60C-7046-4665-8A79-0E2AA85C43EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
1818
{C73EA60C-7046-4665-8A79-0E2AA85C43EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
1919
{C73EA60C-7046-4665-8A79-0E2AA85C43EC}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{0C128A21-F05D-4966-8EC6-F9292A259AA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{0C128A21-F05D-4966-8EC6-F9292A259AA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{0C128A21-F05D-4966-8EC6-F9292A259AA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{0C128A21-F05D-4966-8EC6-F9292A259AA2}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{E126F465-CD99-4DE3-8AED-2098C2B96DA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{E126F465-CD99-4DE3-8AED-2098C2B96DA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{E126F465-CD99-4DE3-8AED-2098C2B96DA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{E126F465-CD99-4DE3-8AED-2098C2B96DA6}.Release|Any CPU.Build.0 = Release|Any CPU
2424
EndGlobalSection
2525
GlobalSection(SolutionProperties) = preSolution
2626
HideSolutionNode = FALSE
2727
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {70D2BA8F-0D3B-4F03-9F40-FD4E06117555}
30+
EndGlobalSection
2831
EndGlobal
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\Castle.DynamicLinqQueryBuilder\Castle.DynamicLinqQueryBuilder.csproj" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Castle.DynamicLinqQueryBuilder.Example.Models;
2+
using Microsoft.AspNetCore.Mvc;
3+
using System.Diagnostics;
4+
using Castle.DynamicLinqQueryBuilder.Example.Sample;
5+
using Newtonsoft.Json;
6+
using Newtonsoft.Json.Serialization;
7+
8+
namespace Castle.DynamicLinqQueryBuilder.Example.Controllers
9+
{
10+
public class HomeController : Controller
11+
{
12+
private readonly ILogger<HomeController> _logger;
13+
14+
public HomeController(ILogger<HomeController> logger)
15+
{
16+
_logger = logger;
17+
}
18+
19+
public IActionResult Index()
20+
{
21+
var jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
22+
23+
var definitions = typeof(PersonRecord).GetDefaultColumnDefinitionsForType(false);
24+
var people = PersonBuilder.GetPeople();
25+
26+
//Augment the definitions to show advanced scenarios not
27+
//handled by GetDefaultColumnDefinitionsForType(...)
28+
29+
//Let's tweak the generated definition of FirstName to make it
30+
//a select element in jQuery QueryBuilder UI populated by
31+
//the possible values from our dataset
32+
var firstName = definitions.First(p => p.Field.ToLower() == "firstname");
33+
firstName.Values = people.Select(p => p.FirstName).Distinct().ToList();
34+
firstName.Input = "select";
35+
36+
ViewBag.FilterDefinition =
37+
JsonConvert.SerializeObject(definitions, jsonSerializerSettings);
38+
ViewBag.Model = people;
39+
return View();
40+
}
41+
42+
[HttpPost]
43+
public JsonResult Index([FromBody]QueryBuilderFilterRule obj)
44+
{
45+
var people = PersonBuilder.GetPeople().BuildQuery(obj).ToList();
46+
return Json(people);
47+
}
48+
49+
50+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
51+
public IActionResult Error()
52+
{
53+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
54+
}
55+
}
56+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Castle.DynamicLinqQueryBuilder.Example.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
builder.Services.AddControllersWithViews();
5+
6+
var app = builder.Build();
7+
8+
// Configure the HTTP request pipeline.
9+
if (!app.Environment.IsDevelopment())
10+
{
11+
app.UseExceptionHandler("/Home/Error");
12+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
13+
app.UseHsts();
14+
}
15+
16+
app.UseHttpsRedirection();
17+
app.UseStaticFiles();
18+
19+
app.UseRouting();
20+
21+
app.UseAuthorization();
22+
23+
app.MapControllerRoute(
24+
name: "default",
25+
pattern: "{controller=Home}/{action=Index}/{id?}");
26+
27+
app.Run();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:63130",
7+
"sslPort": 44395
8+
}
9+
},
10+
"profiles": {
11+
"Castle.DynamicLinqQueryBuilder.Example": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
14+
"launchBrowser": true,
15+
"applicationUrl": "https://localhost:7288;http://localhost:5288",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"IIS Express": {
21+
"commandName": "IISExpress",
22+
"launchBrowser": true,
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
}
26+
}
27+
}
28+
}

Castle.DynamicLinqQueryBuilder.Samples/Sample/PersonBuilder.cs renamed to Castle.DynamicLinqQueryBuilder.Example/Sample/PersonBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Web;
55
using Newtonsoft.Json;
66

7-
namespace Castle.DynamicLinqQueryBuilder.Samples.Sample
7+
namespace Castle.DynamicLinqQueryBuilder.Example.Sample
88
{
99
public static class PersonBuilder
1010
{

Castle.DynamicLinqQueryBuilder.Samples/Sample/PersonRecord.cs renamed to Castle.DynamicLinqQueryBuilder.Example/Sample/PersonRecord.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace Castle.DynamicLinqQueryBuilder.Samples.Sample
3+
namespace Castle.DynamicLinqQueryBuilder.Example.Sample
44
{
55
public class PersonRecord
66
{

Castle.DynamicLinqQueryBuilder.Samples/Views/Home/Index.cshtml renamed to Castle.DynamicLinqQueryBuilder.Example/Views/Home/Index.cshtml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
@using Castle.DynamicLinqQueryBuilder.Samples.Sample
2-
@{
3-
ViewBag.Title = "Home Page";
1+
@{
2+
ViewData["Title"] = "Home Page";
43
}
54
@section scripts
65
{
@@ -24,7 +23,7 @@
2423
};
2524
var jqueryQueryBuilder = $('#jquery-query-builder');
2625
var jqueryQueryBuilderDom = jqueryQueryBuilder.queryBuilder({
27-
plugins: ['bt-tooltip-errors', 'filter-description'],
26+
plugins: [],
2827
//allow_groups: 0,
2928
allow_empty: true,
3029
filters: filterDefinition,
@@ -91,7 +90,7 @@
9190
});
9291
buildTable = function() {
9392
var tbody = $('#data-table tbody'),
94-
props = ["FirstName", "LastName", "Birthday", "Age", "Address", "City", "State", "ZipCode"];
93+
props = ["firstName", "lastName", "birthday", "age", "address", "city", "state", "zipCode"];
9594
tbody.empty();
9695
$.each(tableData, function(i, reservation) {
9796
var tr = $('<tr>');
@@ -110,9 +109,8 @@
110109
111110
</script>
112111
}
113-
114112
<div class="jumbotron">
115-
<h1>Dynamic Linq Query Builder Sample</h1>
113+
<h1>Dynamic Linq Query Builder Example</h1>
116114
<p class="lead">Dynamically filter object collections based on complex queries at runtime.</p>
117115
</div>
118116

@@ -126,19 +124,19 @@
126124
<h2>User Data</h2>
127125
<table id="data-table">
128126
<thead>
129-
<tr>
130-
<th>First Name</th>
131-
<th>Last Name</th>
132-
<th>Birthday</th>
133-
<th>Age</th>
134-
<th>Address</th>
135-
<th>City</th>
136-
<th>State</th>
137-
<th>Zip Code</th>
138-
</tr>
127+
<tr>
128+
<th>First Name</th>
129+
<th>Last Name</th>
130+
<th>Birthday</th>
131+
<th>Age</th>
132+
<th>Address</th>
133+
<th>City</th>
134+
<th>State</th>
135+
<th>Zip Code</th>
136+
</tr>
139137
</thead>
140138
<tbody></tbody>
141139
</table>
142140
</div>
143141

144-
</div>
142+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@model ErrorViewModel
2+
@{
3+
ViewData["Title"] = "Error";
4+
}
5+
6+
<h1 class="text-danger">Error.</h1>
7+
<h2 class="text-danger">An error occurred while processing your request.</h2>
8+
9+
@if (Model.ShowRequestId)
10+
{
11+
<p>
12+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
13+
</p>
14+
}
15+
16+
<h3>Development Mode</h3>
17+
<p>
18+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
19+
</p>
20+
<p>
21+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
22+
It can result in displaying sensitive information from exceptions to end users.
23+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
24+
and restarting the app.
25+
</p>

0 commit comments

Comments
 (0)