Lesson13 - Examples (PS11-12 Hoh Jungi)

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Official (Closed) - Non Sensitive

PS11-12 Hoh Jungi

Lesson13Eg1

Filename: .\Pages\Index.cshtml
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}

<div class="text-center">
<h1 class="display-4">Welcome Jungi</h1>
<p><a href="Calculator">Jungi's Calculator</a></p>
</div>

LastSaved 00000000T0000 page 1 of 5 (Leave the footer alone!)


Official (Closed) - Non Sensitive
PS11-12 Hoh Jungi

When the webpage first loads

After filling in the text boxes and clicking on the “Pearls” and “Custard” checkboxes and “No Ice”
radio button automatically enabled

LastSaved 00000000T0000 page 2 of 5 (Leave the footer alone!)


Official (Closed) - Non Sensitive
PS11-12 Hoh Jungi

After filling in the text boxes and clicking on the "Add" button

After filling in the text boxes and clicking on the "Subtract" button

LastSaved 00000000T0000 page 3 of 5 (Leave the footer alone!)


Official (Closed) - Non Sensitive
PS11-12 Hoh Jungi

Filename: .\Pages\BubbleTea.cshtml
@page
@model RazorPagesBasics.Pages.BubbleTeaModel
@{
ViewData["Title"] = "Bubble Tea Shop";
}
<h1>Bubble Tea</h1>
<form method="post">
<p>
Name: <input type="text" asp-for="Name" />
Contact Number: <input type="text" asp-for="ContactNumber" />
</p>
<p>
<input type="radio" asp-for="IceOption" value="With Ice" disabled />With Ice<br />
<input type="radio" asp-for="IceOption" value="No Ice" checked="checked" />No Ice<br />
</p>
<p>
<input type="checkbox" asp-for="AddBubble" /> Pearls<br />
<input type="checkbox" asp-for="AddCustard" /> Custard<br />
</p>
<p>
<input type="submit" value="OK" />
</p>
<p>Customer Information: @Model.CustomerInfo</p>
<p>Order Information: @Model.OrderInfo</p>
<p>Total Cost: @Model.TotalCost</p>
</form>

LastSaved 00000000T0000 page 4 of 5 (Leave the footer alone!)


Official (Closed) - Non Sensitive
PS11-12 Hoh Jungi

Filename: .\Pages\BubbleTea.cshtml.cs
namespace RazorPagesBasics.Pages
{
public class BubbleTeaModel : PageModel
{
[BindProperty]
public string Name { get; set; }
[BindProperty]
public string ContactNumber { get; set; }
[BindProperty]
public string IceOption { get; set; }
[BindProperty]
public bool AddBubble { get; set; }
[BindProperty]
public bool AddCustard { get; set; }
public string CustomerInfo { get; set; }
public string OrderInfo { get; set; }

public float TotalCost;


public void OnPost()
{
CustomerInfo = Name + " " + ContactNumber;
TotalCost = 2.80f;

if (IceOption == "With Ice")


{
OrderInfo = "With Ice";
}
else if (IceOption == "No Ice")
{
OrderInfo = "No Ice";
}
if (AddBubble == true)
{
OrderInfo += " add bubble";
TotalCost = 0.50f;
}
if (AddCustard == true)
{
OrderInfo += " add custard";
TotalCost = 1.20f;
}
}
}
}

LastSaved 00000000T0000 page 5 of 5 (Leave the footer alone!)

You might also like