-
Notifications
You must be signed in to change notification settings - Fork 14
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
Jill Balzano
authored and
Jill Balzano
committed
Jan 10, 2019
0 parents
commit 7863215
Showing
287 changed files
with
27,059 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,14 @@ | ||
# Contributing to Apress Source Code | ||
|
||
Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. | ||
|
||
## How to Contribute | ||
|
||
1. Make sure you have a GitHub account. | ||
2. Fork the repository for the relevant book. | ||
3. Create a new branch on which to make your change, e.g. | ||
`git checkout -b my_code_contribution` | ||
4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. | ||
5. Submit a pull request. | ||
|
||
Thank you for your contribution! |
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,27 @@ | ||
Freeware License, some rights reserved | ||
|
||
Copyright (c) 2018 Peter Himschoot | ||
|
||
Permission is hereby granted, free of charge, to anyone obtaining a copy | ||
of this software and associated documentation files (the "Software"), | ||
to work with the Software within the limits of freeware distribution and fair use. | ||
This includes the rights to use, copy, and modify the Software for personal use. | ||
Users are also allowed and encouraged to submit corrections and modifications | ||
to the Software for the benefit of other users. | ||
|
||
It is not allowed to reuse, modify, or redistribute the Software for | ||
commercial use in any way, or for a user’s educational materials such as books | ||
or blog articles without prior permission from the copyright holder. | ||
|
||
The above copyright notice and this permission notice need to be included | ||
in all copies or substantial portions of the software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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,5 @@ | ||
<!-- | ||
Configuring this here is temporary. Later we'll move the app config | ||
into Program.cs, and it won't be necessary to specify AppAssembly. | ||
--> | ||
<Router AppAssembly=typeof(Program).Assembly /> |
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,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace PizzaPlace070.Client | ||
{ | ||
public static class DebuggingExtensions | ||
{ | ||
public static string ToJson(this object obj) | ||
=> Microsoft.JSInterop.Json.Serialize(obj); | ||
} | ||
|
||
} |
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,16 @@ | ||
@page "/counter" | ||
|
||
<h1>Counter</h1> | ||
|
||
<p>Current count: @currentCount</p> | ||
|
||
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button> | ||
|
||
@functions { | ||
int currentCount = 0; | ||
|
||
void IncrementCount() | ||
{ | ||
currentCount++; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
PizzaPlace070/PizzaPlace070.Client/Pages/CustomerEntry.cshtml
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,44 @@ | ||
@using PizzaPlace070.Shared | ||
|
||
@addTagHelper *, PizzaPlace070.Extensions.Validation | ||
|
||
<h1>@Title</h1> | ||
|
||
<fieldset> | ||
<p> | ||
<label for="name">Name:</label> | ||
<input id="name" bind="@Customer.Name" /> | ||
<ValidationError Subject="@Customer" | ||
Property="@nameof(Customer.Name)" /> | ||
</p> | ||
<p> | ||
<label for="street">Street:</label> | ||
<input id="street" bind="@Customer.Street" /> | ||
<ValidationError Subject="@Customer" | ||
Property="@nameof(Customer.Street)" /> | ||
</p> | ||
<p> | ||
<label for="city">City:</label> | ||
<input id="city" bind="@Customer.City" /> | ||
<ValidationError Subject="@Customer" | ||
Property="@nameof(Customer.City)" /> | ||
</p> | ||
|
||
<button onclick="@(()=>Submit(Customer))" | ||
disabled="@Customer.HasErrors"> | ||
Checkout | ||
</button> | ||
</fieldset> | ||
|
||
@functions { | ||
|
||
[Parameter] | ||
protected string Title { get; set; } | ||
|
||
[Parameter] | ||
protected Customer Customer { get; set; } | ||
|
||
[Parameter] | ||
protected Action<Customer> Submit { 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,45 @@ | ||
@using PizzaPlace070.Shared | ||
@page "/fetchdata" | ||
@inject HttpClient Http | ||
|
||
<h1>Weather forecast</h1> | ||
|
||
<p>This component demonstrates fetching data from the server.</p> | ||
|
||
@if (forecasts == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Date</th> | ||
<th>Temp. (C)</th> | ||
<th>Temp. (F)</th> | ||
<th>Summary</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var forecast in forecasts) | ||
{ | ||
<tr> | ||
<td>@forecast.Date.ToShortDateString()</td> | ||
<td>@forecast.TemperatureC</td> | ||
<td>@forecast.TemperatureF</td> | ||
<td>@forecast.Summary</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
|
||
@functions { | ||
WeatherForecast[] forecasts; | ||
|
||
protected override async Task OnInitAsync() | ||
{ | ||
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("api/SampleData/WeatherForecasts"); | ||
} | ||
} |
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,83 @@ | ||
@page "/" | ||
@using PizzaPlace070.Shared | ||
@using Microsoft.AspNetCore.Blazor.Services | ||
@inject IMenuService menuService | ||
@inject IOrderService orderService | ||
@inject State State | ||
@inject IUriHelper UriHelper | ||
<!-- Menu --> | ||
|
||
<PizzaList Title="Our selected list of pizzas" | ||
Menu="@State.Menu" | ||
Selected="@((pizza) => AddToBasket(pizza))" | ||
ShowPizzaInformation="@((pizza) => ShowPizzaInformation(pizza))" /> | ||
|
||
<!-- End menu --> | ||
<!-- Shopping Basket --> | ||
|
||
<ShoppingBasket Title="Your current order" | ||
Basket="@State.Basket" | ||
GetPizzaFromId="@State.Menu.GetPizza" | ||
Selected="@(pos => RemoveFromBasket(pos))" /> | ||
|
||
<!-- End shopping basket --> | ||
<!-- Customer entry --> | ||
<CustomerEntry Title="Please enter your details below" | ||
Customer="@State.Basket.Customer" | ||
Submit="@(async (_) => await PlaceOrder())" /> | ||
<!-- End customer entry --> | ||
|
||
<p>@State.ToJson()</p> | ||
|
||
@functions { | ||
|
||
protected override async Task OnInitAsync() | ||
{ | ||
this.State.Menu = await menuService.GetMenu(); | ||
this.State.Basket.Customer.PropertyChanged += | ||
(sender, e) => this.StateHasChanged(); | ||
} | ||
|
||
//private State State { get; } = new State(); | ||
//{ | ||
// Menu = new Menu | ||
// { | ||
// Pizzas = new List<Pizza> | ||
//{ | ||
//new Pizza(1, "Pepperoni", 8.99M, Spiciness.Spicy ), | ||
//new Pizza(2, "Margarita", 7.99M, Spiciness.None ), | ||
//new Pizza(3, "Diabolo", 9.99M, Spiciness.Hot ) | ||
//} | ||
// } | ||
//}; | ||
private string SpicinessImage(Spiciness spiciness) | ||
=> $"images/{spiciness.ToString().ToLower()}.png"; | ||
|
||
private void AddToBasket(Pizza pizza) | ||
{ | ||
Console.WriteLine($"Added pizza {pizza.Name}"); | ||
State.Basket.Add(pizza.Id); | ||
StateHasChanged(); | ||
} | ||
|
||
private void RemoveFromBasket(int pos) | ||
{ | ||
Console.WriteLine($"Removing pizza at pos {pos}"); | ||
State.Basket.RemoveAt(pos); | ||
StateHasChanged(); | ||
} | ||
|
||
private async Task PlaceOrder() | ||
{ | ||
//Console.WriteLine("Placing order"); | ||
await orderService.PlaceOrder(State.Basket); | ||
} | ||
|
||
private void ShowPizzaInformation(Pizza pizza) | ||
{ | ||
State.CurrentPizza = pizza; | ||
UriHelper.NavigateTo("/PizzaInfo"); | ||
} | ||
|
||
} |
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,33 @@ | ||
@page "/PizzaInfo" | ||
@using PizzaPlace070.Shared | ||
@inject State State | ||
|
||
<h2>Pizza Details</h2> | ||
|
||
<div class="row"> | ||
<div class="col"> | ||
@State.CurrentPizza.Name | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col"> | ||
@State.CurrentPizza.Price | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col"> | ||
<img src="@SpicinessImage(State.CurrentPizza.Spiciness)" | ||
alt="@State.CurrentPizza.Spiciness" /> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col"> | ||
<a class="btn btn-primary" href="/">Menu</a> | ||
</div> | ||
</div> | ||
|
||
@functions { | ||
|
||
private string SpicinessImage(Spiciness spiciness) | ||
=> $"images/{spiciness.ToString().ToLower()}.png"; | ||
} |
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,45 @@ | ||
@using PizzaPlace070.Shared | ||
|
||
<div class="row"> | ||
<div class="col"> | ||
<a href="" | ||
onclick="@(() => ShowPizzaInformation(Pizza))"> | ||
@Pizza.Name | ||
</a> | ||
</div> | ||
<div class="col"> | ||
@Pizza.Price | ||
</div> | ||
<div class="col"> | ||
<img src="@SpicinessImage(Pizza.Spiciness)" | ||
alt="@Pizza.Spiciness" /> | ||
</div> | ||
<div class="col"> | ||
<button class="@ButtonClass" | ||
onclick="@(() => Selected(Pizza))"> | ||
@ButtonTitle | ||
</button> | ||
</div> | ||
</div> | ||
|
||
@functions { | ||
|
||
[Parameter] | ||
protected Pizza Pizza { get; set; } | ||
|
||
[Parameter] | ||
protected string ButtonTitle { get; set; } | ||
|
||
[Parameter] | ||
protected string ButtonClass { get; set; } | ||
|
||
[Parameter] | ||
protected Action<Pizza> Selected { get; set; } | ||
|
||
[Parameter] | ||
protected Action<Pizza> ShowPizzaInformation { get; set; } | ||
|
||
private string SpicinessImage(Spiciness spiciness) | ||
=> $"images/{spiciness.ToString().ToLower()}.png"; | ||
|
||
} |
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,43 @@ | ||
@using PizzaPlace070.Shared | ||
|
||
<h1>@Title</h1> | ||
@if (Menu == null || Menu.Pizzas == null || Menu.Pizzas.Count == 0) | ||
{ | ||
<div style="height:20vh;" class="pt-3"> | ||
<div class="mx-left pt-3" style="width:200px"> | ||
<div class="progress"> | ||
<div class="progress-bar bg-danger | ||
progress-bar-striped | ||
progress-bar-animated w-100" | ||
role="progressbar" | ||
aria-valuenow="100" aria-valuemin="0" | ||
aria-valuemax="100"></div> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
else | ||
{ | ||
@foreach (var pizza in Menu.Pizzas) | ||
{ | ||
<PizzaItem Pizza="@pizza" ButtonTitle="Order" | ||
ButtonClass="btn btn-success" | ||
Selected="@((p) => Selected(p))" | ||
ShowPizzaInformation="@ShowPizzaInformation" /> | ||
} | ||
} | ||
|
||
@functions { | ||
|
||
[Parameter] | ||
protected string Title { get; set; } | ||
|
||
[Parameter] | ||
protected Menu Menu { get; set; } | ||
|
||
[Parameter] | ||
protected Action<Pizza> Selected { get; set; } | ||
|
||
[Parameter] | ||
protected Action<Pizza> ShowPizzaInformation { get; set; } | ||
} |
Oops, something went wrong.