-
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
35 changed files
with
1,337 additions
and
14 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
17 changes: 15 additions & 2 deletions
17
EinsamerWanderer.API/DbContexts/EinsamerWandererDbContext.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
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,11 @@ | ||
using System; | ||
|
||
namespace EinsamerWanderer.API.Model | ||
{ | ||
public class Character | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } | ||
public long Experience { get; set; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace EinsamerWanderer.Shared.Request | ||
{ | ||
public class CreateItemRequest | ||
{ | ||
public string Name { get; set; } | ||
public double Value { get; set; } | ||
} | ||
} |
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,8 @@ | ||
namespace EinsamerWanderer.Shared.Request | ||
{ | ||
public class UpdateItemRequest | ||
{ | ||
public string Name { get; set; } | ||
public double Value { get; set; } | ||
} | ||
} |
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,11 @@ | ||
using System; | ||
|
||
namespace EinsamerWanderer.Shared.Request | ||
{ | ||
public class ItemResponse | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } | ||
public double Value { get; set; } | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
EinsamerWanderer.API/RestContract/V1/Item.cs → ...erWanderer.Shared/RestContract/V1/Item.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
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,10 @@ | ||
<Router AppAssembly="@typeof(Program).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
</Found> | ||
<NotFound> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p>Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
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,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<RazorLangVersion>3.0</RazorLangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" /> | ||
<PackageReference Include="System.Net.Http.Json" Version="3.2.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EinsamerWanderer.Shared\EinsamerWanderer.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,23 @@ | ||
@page "/addItem" | ||
@using EinsamerWanderer.Shared.Request | ||
@using EinsamerWanderer.Shared.RestContract.V1 | ||
@inject HttpClient Http | ||
|
||
|
||
<h3>AddItem</h3> | ||
|
||
<EditForm Model="@_createItemRequest" OnValidSubmit="@HandleValidSubmit"> | ||
<input id="Name" @bind="_createItemRequest.Name" /> | ||
<input id="Value" @bind="_createItemRequest.Value" /> | ||
<button type="submit">Submit</button> | ||
</EditForm> | ||
|
||
@code { | ||
private CreateItemRequest _createItemRequest = new CreateItemRequest(); | ||
|
||
private void HandleValidSubmit() | ||
{ | ||
Http.PostAsJsonAsync("http://localhost:5000" + Routes.Item.Create, _createItemRequest); | ||
} | ||
|
||
} |
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,32 @@ | ||
@page "/changeItem/{itemId}" | ||
@using EinsamerWanderer.Shared.Request | ||
@using EinsamerWanderer.Shared.RestContract.V1 | ||
@inject HttpClient Http | ||
@inject NavigationManager NavigationManager | ||
<h3>ChangeItem</h3> | ||
|
||
<EditForm Model="@_updateItemRequest" OnValidSubmit="@HandleValidSubmit"> | ||
<input id="Name" @bind="_updateItemRequest.Name" /> | ||
<input id="Value" @bind="_updateItemRequest.Value" /> | ||
<button type="submit">Submit</button> | ||
</EditForm> | ||
|
||
@code { | ||
[Parameter] | ||
public string ItemId { get; set; } | ||
private UpdateItemRequest _updateItemRequest = new UpdateItemRequest(); | ||
protected override async Task OnInitializedAsync() | ||
{ | ||
var response = await Http.GetFromJsonAsync<ItemResponse>( | ||
"http://localhost:5000" + Routes.Item.Get.Replace("{itemId}", ItemId)); | ||
_updateItemRequest.Value = response.Value; | ||
_updateItemRequest.Name = response.Name; | ||
} | ||
|
||
private async void HandleValidSubmit() | ||
{ | ||
await Http.PutAsJsonAsync("http://localhost:5000" + Routes.Item.Update.Replace("{itemId}", ItemId), _updateItemRequest); | ||
NavigationManager.NavigateTo("/items"); | ||
} | ||
|
||
} |
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,7 @@ | ||
@page "/" | ||
|
||
<h1>Hello, world!</h1> | ||
|
||
Welcome to your new app. | ||
|
||
<SurveyPrompt Title="How is Blazor working for you?" /> |
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,60 @@ | ||
@using EinsamerWanderer.Shared.Request | ||
@using EinsamerWanderer.Shared.RestContract.V1 | ||
|
||
@inject NavigationManager NavigationManager | ||
@inject HttpClient Http | ||
@page "/Items" | ||
<h3>Items</h3> | ||
|
||
<div class="justify-content-center "> | ||
<button @onclick="NavigateToAdd" class="btn btn-info">Add</button> | ||
<table class="table table-responsive w-50"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Name</th> | ||
<th scope="col">Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var item in _itemResponses) | ||
{ | ||
var varItem = item; | ||
<tr> | ||
<td>@item.Name</td> | ||
<td>@item.Value</td> | ||
<td> | ||
<button @onclick="@(() => NavigateToChange(varItem.Id))" class="btn btn-light btn-lg">Change</button> | ||
</td> | ||
<td> | ||
<button @onclick="@(() => RemoveItem(varItem.Id))" class="btn btn-light">X</button> | ||
</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
</div> | ||
@code { | ||
private List<ItemResponse> _itemResponses = new List<ItemResponse>(); | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
_itemResponses = await Http.GetFromJsonAsync<List<ItemResponse>>("http://localhost:5000" + Routes.Item.GetAll); | ||
} | ||
|
||
private void NavigateToAdd() | ||
{ | ||
NavigationManager.NavigateTo("/AddItem"); | ||
} | ||
|
||
private void NavigateToChange(Guid itemId) | ||
{ | ||
NavigationManager.NavigateTo($"/ChangeItem/{itemId.ToString()}"); | ||
} | ||
|
||
private async Task RemoveItem(Guid itemId) | ||
{ | ||
await Http.DeleteAsync("http://localhost:5000" + Routes.Item.Delete.Replace("{itemId}", itemId.ToString())); | ||
_itemResponses.Remove(_itemResponses.FirstOrDefault(x => x.Id == itemId)); | ||
} | ||
|
||
} |
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,25 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using System.Text; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace EinsamerWanderer.Web | ||
{ | ||
public class Program | ||
{ | ||
public static async Task Main(string[] args) | ||
{ | ||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
builder.RootComponents.Add<App>("app"); | ||
|
||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); | ||
|
||
await builder.Build().RunAsync(); | ||
} | ||
} | ||
} |
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,29 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:56973", | ||
"sslPort": 44393 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"EinsamerWanderer.Web": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", | ||
"applicationUrl": "https://localhost:5001;http://localhost:5005", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
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,15 @@ | ||
@inherits LayoutComponentBase | ||
|
||
<div class="sidebar"> | ||
<NavMenu /> | ||
</div> | ||
|
||
<div class="main"> | ||
<div class="top-row px-4"> | ||
<a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a> | ||
</div> | ||
|
||
<div class="content px-4"> | ||
@Body | ||
</div> | ||
</div> |
Oops, something went wrong.