Finalizing base dependency injection.
This commit is contained in:
parent
14ebe20a56
commit
82edd11e08
|
@ -15,13 +15,19 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav-item px-3">
|
<div class="nav-item px-3">
|
||||||
<NavLink class="nav-link" href="weather">
|
<NavLink class="nav-link" href="articles">
|
||||||
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-journal-richtext" viewBox="0 0 16 16">
|
||||||
|
<path d="M7.5 3.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m-.861 1.542 1.33.886 1.854-1.855a.25.25 0 0 1 .289-.047L11 4.75V7a.5.5 0 0 1-.5.5h-5A.5.5 0 0 1 5 7v-.5s1.54-1.274 1.639-1.208M5 9.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5" />
|
||||||
|
<path d="M3 0h10a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2v-1h1v1a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v1H1V2a2 2 0 0 1 2-2" />
|
||||||
|
<path d="M1 5v-.5a.5.5 0 0 1 1 0V5h.5a.5.5 0 0 1 0 1h-2a.5.5 0 0 1 0-1zm0 3v-.5a.5.5 0 0 1 1 0V8h.5a.5.5 0 0 1 0 1h-2a.5.5 0 0 1 0-1zm0 3v-.5a.5.5 0 0 1 1 0v.5h.5a.5.5 0 0 1 0 1h-2a.5.5 0 0 1 0-1z" />
|
||||||
|
</svg> Articles
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav-item px-3">
|
<div class="nav-item px-3">
|
||||||
<NavLink class="nav-link" href="pokemonsleep">
|
<NavLink class="nav-link" href="pokemonsleep">
|
||||||
<span class="bi bi-p-circle-fill" aria-hidden="true"></span> Pokemon Sleep
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-p-circle-fill" viewBox="0 0 16 16">
|
||||||
|
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.5 4.002V12h1.283V9.164h1.668C10.033 9.164 11 8.08 11 6.586c0-1.482-.955-2.584-2.538-2.584zm2.77 4.072c.893 0 1.419-.545 1.419-1.488s-.526-1.482-1.42-1.482H6.778v2.97z" />
|
||||||
|
</svg> Pokemon Sleep
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
@page "/articles"
|
||||||
|
|
||||||
|
@inject IArticleService ArticleService
|
||||||
|
|
||||||
|
<PageTitle>Articles</PageTitle>
|
||||||
|
<h3>Articles</h3>
|
||||||
|
|
||||||
|
@if(articles.Count == 0)
|
||||||
|
{
|
||||||
|
<p><em>Loading...</em></p>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@foreach(var article in articles)
|
||||||
|
{
|
||||||
|
<h4>@article.Title</h4>
|
||||||
|
<p>@article.Content</p>
|
||||||
|
<small>@article.DatePublished</small>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private List<Article> articles = new List<Article>();
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
var result = ArticleService.GetAllArticles();
|
||||||
|
if (result is not null)
|
||||||
|
{
|
||||||
|
articles = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,64 +1,90 @@
|
||||||
@page "/pokemonsleep"
|
@page "/pokemonsleep"
|
||||||
|
@inject IPokemonService PokemonService
|
||||||
|
|
||||||
@attribute [StreamRendering]
|
@attribute [StreamRendering]
|
||||||
|
|
||||||
<PageTitle>Pokemon Sleep</PageTitle>
|
<PageTitle>Pokemon Sleep</PageTitle>
|
||||||
|
|
||||||
<h1>Pokemon Sleep</h1>
|
<h1>Pokemon Sleep</h1>
|
||||||
|
|
||||||
<p>This component will eventually show data from the PokemonSleepAPI. For right now it copies Weather.</p>
|
@if (pokemons == null)
|
||||||
|
|
||||||
@if (forecasts == null)
|
|
||||||
{
|
{
|
||||||
<p><em>Loading...</em></p>
|
<p><em>Loading...</em></p>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<table class="table">
|
<div class="card shadow border-0 mt-4" style ="margin: auto; width: 900px; max-width: 60%; ">
|
||||||
<thead>
|
|
||||||
<tr>
|
<div class="card-header bg-secondary bg-gradient ml-0 py-3">
|
||||||
<th>Date</th>
|
<div class="row">
|
||||||
<th>Temp. (C)</th>
|
<div class="col-12 text-center">
|
||||||
<th>Temp. (F)</th>
|
<h1 class="text-info">Available Pokemon</h1>
|
||||||
<th>Summary</th>
|
</div>
|
||||||
</tr>
|
</div>
|
||||||
</thead>
|
</div>
|
||||||
<tbody>
|
<div class="card-body p-4">
|
||||||
@foreach (var forecast in forecasts)
|
<div class="row pb-3">
|
||||||
{
|
<div class="col-6">
|
||||||
|
</div>
|
||||||
|
<div class="col-6 text-end">
|
||||||
|
<a asp-controller="Pokemon" asp-action="PokemonCreate" class="btn btn-outline-primary"><i class="bi bi-plus-square"></i> Add New Pokemon</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>@forecast.Date.ToShortDateString()</td>
|
<th scope="col" style="width: 50%;"></th>
|
||||||
<td>@forecast.TemperatureC</td>
|
<th scope="col">#</th>
|
||||||
<td>@forecast.TemperatureF</td>
|
<th scope="col">Pokemon</th>
|
||||||
<td>@forecast.Summary</td>
|
<th scope="col">Sleep Type</th>
|
||||||
|
<th scope="col" style="padding-right: 30px;">Speciality</th>
|
||||||
|
<th scope="col"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var pokemon in pokemons)
|
||||||
|
{
|
||||||
|
string URL = "https://www.serebii.net/pokemonsleep/pokemon/" + pokemon.Id + ".png";
|
||||||
|
string ShinyURL = "https://www.serebii.net/pokemonsleep/pokemon/shiny/" + pokemon.Id + ".png";
|
||||||
|
|
||||||
|
<tr style=" text-align: center; margin:0; padding: 0;">
|
||||||
|
<td style="display: block; margin:0; padding: 0;">
|
||||||
|
<img style=" width: 90px; height: 90px; " src=@URL />
|
||||||
|
<img style=" width: 90px; height: 90px; " src=@ShinyURL />
|
||||||
|
</td>
|
||||||
|
<th scope="row">@pokemon.Id</th>
|
||||||
|
<td> @pokemon.PokemonName</td>
|
||||||
|
<td>@pokemon.SleepType</td>
|
||||||
|
<td style="padding-right: 30px;">@pokemon.Speciality</td>
|
||||||
|
<td>
|
||||||
|
<a asp-controller="Pokemon" asp-action="PokemonDelete" asp-route-Id="@pokemon.Id" class="btn btn-danger">
|
||||||
|
<i class="bi bi-trash"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private WeatherForecast[]? forecasts;
|
private List<Pokemon> pokemons;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
// Simulate asynchronous loading to demonstrate streaming rendering
|
// Simulate asynchronous loading to demonstrate streaming rendering
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
|
|
||||||
var startDate = DateOnly.FromDateTime(DateTime.Now);
|
var result = PokemonService.GetAllPokemon();
|
||||||
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
|
if (result is not null)
|
||||||
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
{
|
||||||
{
|
pokemons = result;
|
||||||
Date = startDate.AddDays(index),
|
}
|
||||||
TemperatureC = Random.Shared.Next(-20, 55),
|
|
||||||
Summary = summaries[Random.Shared.Next(summaries.Length)]
|
|
||||||
}).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class WeatherForecast
|
|
||||||
{
|
|
||||||
public DateOnly Date { get; set; }
|
|
||||||
public int TemperatureC { get; set; }
|
|
||||||
public string? Summary { get; set; }
|
|
||||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,3 +8,8 @@
|
||||||
@using Microsoft.JSInterop
|
@using Microsoft.JSInterop
|
||||||
@using Portfolio.WebUI.Server
|
@using Portfolio.WebUI.Server
|
||||||
@using Portfolio.WebUI.Server.Components
|
@using Portfolio.WebUI.Server.Components
|
||||||
|
@using Portfolio.Domain.Features.Articles
|
||||||
|
@using Portfolio.Domain.Features.Pokemon
|
||||||
|
@using Portfolio.Application.Services.Articles
|
||||||
|
@using Portfolio.Application.Services.PokemonService
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
using Portfolio.WebUI.Server.Components;
|
using Portfolio.WebUI.Server.Components;
|
||||||
|
using Portfolio.Application;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddRazorComponents();
|
builder.Services.AddRazorComponents();
|
||||||
|
|
||||||
|
builder.Services.AddApplication();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue