You are on page 1of 5

Official (Closed) - Non Sensitive

PS11-12 Hoh Jungi

Lesson12Ex1

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>
<p><a href="BookOrder">Jungi's Book Order</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 "Calculate Total Price" button

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 "Confirm" button

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


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

Filename: .\Pages\BookOrder.cshtml
@page
@model RazorPagesBasics.Pages.BookOrderModel
@{
}
<h1>Book Order (Hoh Jungi 10243292F)</h1>
<form method="post">
<p>
Title: <input type="text" asp-for="Title" />
Author: <input type="text" asp-for="Author" />
</p>
<p>
Quantity: <input type="text" asp-for="Quantity" />
Price: $<input type="text" asp-for="Price" />
</p>
<p>
<input type="submit" value="Calculate Total Price" />
<input type="submit" asp-page-handler="Confirm" value="Confirm" />
</p>
<p>@Model.Answer</p>
</form>

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


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

Filename: .\Pages\BookOrder.cshtml.cs
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace RazorPagesBasics.Pages
{
public class BookOrderModel : PageModel
{
[BindProperty]
public string Title { get; set; }
[BindProperty]
public string Author { get; set; }
[BindProperty]
public int Quantity { get; set; }
[BindProperty]
public float Price { get; set; }
public string Answer { get; set; }
public void OnPost()
{
float TotalCost = Quantity * Price;
Answer = "Total cost = $" + TotalCost.ToString();
}
public void OnPostConfirm()
{
float TotalCost = Quantity * Price;
Answer = "Order confirmed: " + Quantity + " copies of " + Title + " by " + Author + ". Total cost = $" +
TotalCost.ToString();
}
}
}

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

You might also like