Created
January 24, 2021 07:53
-
-
Save JIOO-phoeNIX/33741d1f27f5ec0c93943dbb3193dc76 to your computer and use it in GitHub Desktop.
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
@page "/EmployeeView" | |
@using GraphQLSampleAppUI.DataAccess; | |
@using GraphQLSampleAppUI.DataAccess.Model; | |
@inject NavigationManager NavigationManager | |
<h1>All Employee</h1> | |
<a href="/CreateEmployee">Create an Employee</a> | |
@if (AllEmployees.Count == 0) | |
{ | |
<p><em>Loading...</em></p> | |
} | |
else | |
{ | |
<table class="table"> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Email</th> | |
<th>Age</th> | |
<th>Department Name</th> | |
</tr> | |
</thead> | |
<tbody> | |
@foreach (var emp in AllEmployees) | |
{ | |
<tr> | |
<td><a href="/ViewEmployee/@emp.EmployeeId">@emp.Name</a> </td> | |
<td>@emp.Email</td> | |
<td>@emp.Age</td> | |
<td>@emp.Department.Name</td> | |
</tr> | |
} | |
</tbody> | |
</table> | |
} | |
@code { | |
private List<Employee> AllEmployees = new List<Employee>(); | |
protected override async Task OnInitializedAsync() | |
{ | |
try | |
{ | |
string completeQuery = "query{allEmployeeWithDepartment{name,age,departmentId,email,employeeId,department{name,departmentId}}}"; | |
string graphQLQueryType = "allEmployeeWithDepartment"; | |
var result = await Query.ExceuteQueryReturnListAsyn<Employee>(graphQLQueryType, completeQuery); | |
AllEmployees = result; | |
} | |
catch (Exception ex) | |
{ | |
throw ex; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment