forked from vb-consulting/PgRoutinerDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
325 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,90 @@ | ||
@page "/" | ||
|
||
@inject HttpClient Http | ||
@using System.Text.Json | ||
|
||
<_Nav BrandContent="PgRoutiner Demo"></_Nav> | ||
|
||
<main class="container vh-100"> | ||
|
||
<div>hai worldz</div> | ||
<div class="row filter"> | ||
<div class="col form-group input-group"> | ||
<input type="text" class="form-control" | ||
autocorrect="off" autocapitalize="off" spellcheck="false" | ||
placeholder="Search by name..." /> | ||
<select class="form-select-lg"> | ||
<option selected>Select area...</option> | ||
@foreach (var area in areas) | ||
{ | ||
<option value="@area.Id">@area.Name</option> | ||
} | ||
</select> | ||
</div> | ||
</div> | ||
|
||
</main> | ||
<div class="row"> | ||
<div class="col"> | ||
<button type="button" class="btn btn-primary"> | ||
<i class="icon-doc-new" /> | ||
Add New | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div class="row pager"> | ||
<div class="col"> | ||
<button type="button" class="btn btn-sm btn-outline-primary"> | ||
First | ||
</button> | ||
<button type="button" class="btn btn-sm btn-outline-primary"> | ||
Last | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
|
||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th scope="col"></th> | ||
<th scope="col">Company</th> | ||
<th scope="col">Website</th> | ||
<th scope="col">Area</th> | ||
<th scope="col">About</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var company in result.Page ?? Enumerable.Empty<SearchResultPage>()) | ||
{ | ||
<tr> | ||
<th scope="row"> | ||
<button type="button" class="btn btn-sm btn-outline-primary icon-edit"></button> | ||
</th> | ||
<td>@company.Name</td> | ||
<td>@company.Website</td> | ||
<td>@company.Area</td> | ||
<td>@company.About</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
|
||
</div> | ||
|
||
</main> | ||
<_Footer></_Footer> | ||
|
||
@code { | ||
private IEnumerable<CompanyArea> areas = Enumerable.Empty<CompanyArea>(); | ||
private SearchResults result = new(); | ||
|
||
private const int pageSize = 10; | ||
private int page = 1; | ||
private SearchFilter filter = new(); | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
areas = await Http.GetFromJsonAsync<IEnumerable<CompanyArea>>("/companies/areas"); | ||
var f = Uri.EscapeDataString(JsonSerializer.Serialize(filter, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase })); | ||
result = await Http.GetFromJsonAsync<SearchResults>($"/companies/{f}/{page}/{pageSize}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
main{padding-top:65px}main .filter input,main .filter select{margin-top:10px;margin-bottom:10px}main .filter input{max-width:50%}main .filter select{margin-left:10px !important}main .pager{margin-top:25px} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
main { | ||
padding-top: 65px; | ||
|
||
.filter { | ||
input, select { | ||
margin-top: 10px; | ||
margin-bottom: 10px; | ||
} | ||
|
||
input { | ||
max-width: 50%; | ||
} | ||
|
||
select { | ||
margin-left: 10px !important; | ||
} | ||
} | ||
|
||
.pager { | ||
margin-top: 25px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
CompaniesWebBlazor/CompaniesDb/Extensions/CompanyAreaReadAll.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// <auto-generated /> | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Norm; | ||
using NpgsqlTypes; | ||
using Npgsql; | ||
using CompaniesWebBlazor.Shared; | ||
|
||
namespace CompaniesDb.Extensions | ||
{ | ||
public static class CompanyAreaReadAll | ||
{ | ||
public const string Name = "company_areas"; | ||
|
||
public const string Sql = @" | ||
SELECT | ||
""id"", | ||
""name"" | ||
FROM | ||
""company_areas"""; | ||
|
||
/// <summary> | ||
/// Select table ""company_areas"" and return enumerator of instances of a "CompaniesDb.Extensions.CompanyArea" class. | ||
/// </summary> | ||
/// <returns>Single instance of a "CompaniesDb.Extensions.CompanyArea" class that is mapped to resulting record of table ""company_areas""</returns> | ||
public static IEnumerable<CompanyArea> ReadCompanyAreaAll(this NpgsqlConnection connection) | ||
{ | ||
return connection | ||
.Prepared() | ||
.Read<CompanyArea>(Sql); | ||
} | ||
|
||
/// <summary> | ||
/// Asynchronously select table ""company_areas"" and return enumerator of instances of a "CompanyArea" class. | ||
/// </summary> | ||
/// <returns>IAsyncEnumerable of "CompaniesDb.Extensions.CompanyArea" instances.</returns> | ||
public static IAsyncEnumerable<CompanyArea> ReadCompanyAreaAllAsync(this NpgsqlConnection connection) | ||
{ | ||
return connection | ||
.Prepared() | ||
.ReadAsync<CompanyArea>(Sql); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
CompaniesWebBlazor/CompaniesDbTests/ReadCompanyAreaAllUnitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// <auto-generated /> | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Norm; | ||
using FluentAssertions; | ||
using CompaniesDb.Extensions; | ||
using CompaniesWebBlazor.Shared; | ||
|
||
namespace CompaniesDbTests | ||
{ | ||
public class ReadCompanyAreaAllUnitTests : PostgreSqlUnitTestFixture | ||
{ | ||
public ReadCompanyAreaAllUnitTests(PostgreSqlFixture fixture) : base(fixture) { } | ||
|
||
[Fact] | ||
public void ReadCompanyAreaAll_Test1() | ||
{ | ||
// Arrange | ||
|
||
// Act | ||
var result = Connection.ReadCompanyAreaAll().ToList(); | ||
|
||
// Assert | ||
new List<CompanyArea> | ||
{ | ||
new CompanyArea{ Id = 1, Name = "IT" }, | ||
new CompanyArea{ Id = 2, Name = "Healthcare" }, | ||
new CompanyArea{ Id = 3, Name = "Finance" }, | ||
new CompanyArea{ Id = 4, Name = "Trade" }, | ||
new CompanyArea{ Id = 5, Name = "AI" }, | ||
new CompanyArea{ Id = 6, Name = "Services" }, | ||
new CompanyArea{ Id = 7, Name = "Marketing" }, | ||
new CompanyArea{ Id = 8, Name = "Production" }, | ||
new CompanyArea{ Id = 9, Name = "Manufacturing" }, | ||
new CompanyArea{ Id = 10, Name = "Transportation" }, | ||
}.Should().BeEquivalentTo(result); | ||
} | ||
} | ||
} |
Oops, something went wrong.