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

Official (Closed) - Non Sensitive

PS11-12 Hoh Jungi

Lesson15Ex1

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>
<p> <a href="BubbleTea">Jungi's Bubble Tea</a></p>
<p> <a href="BurgerShop">Jungi's Burger Shop</a></p>
<p><a href="Cafe">Jungi's Cafe</a></p>
<p><a href="Reservation">Dinner Reservation</a></p>
<p><a href="Appointment">Medical Appointment</a></p>
</div>

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


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

When the webpage first loads

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


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

After filling in all of the text boxes except that Name is not supplied, and Age is invalid but click OK

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


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

After filling in all of the text boxes except that the Appointment Date/Time is too early but click OK

After filling in all of the text boxes with and all validation criteria satisfied

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


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

Filename: .\Pages\Appointment.cshtml
@page
@model RazorPagesBasics.Pages.AppointmentModel
@{
ViewData["Title"] = "Medical Appointment";
}
<h1>Medical Appointment</h1>
<div asp-validation-summary="All"></div>
<form method="post">
<p>
Name <input type="text" asp-for="Name" />
Age (in years) <input type="text" asp-for="Age" />
</p>
<p>
Appointment Date/Time <input type="datetime-local" asp-for="AppointmentDateTime" asp-
format="{0:yyyy-MM-ddTHH:mm}" />
</p>
<p>
<i style="color : red">@Model.ErrorMessage</i>
</p>
<p>
<table class="table">
<thead>
<tr><th>Doctor</th><th>Consultation Fee</th></tr>
</thead>
<tbody>
<tr><td><input type="radio" asp-for="Consult" value="Senior Consultant" checked='checked'> Senior
Consultant</td><td>$200.00</td></tr>
<tr><td><input type="radio" asp-for="Consult" value="Consultant">
Consultant</td><td>$120.00</td></tr>
</tbody>
</table>
</p>
<p>
<input type="checkbox" asp-for="Fever"> Do you currently have any fever symptoms? </br>
<input type="checkbox" asp-for="Overseas"> Have you travelled overseas in the past 14 days? </br>
</p>
<p><input type="submit" value="OK" /></p>
<p>Patient Info: @Model.PatientInfo</p>
<p>Doctor Info: @Model.DoctorInfo</p>
<p>Appointment Date/Time: @Model.strAppointmentDateTime</p>
</form>

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


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

Filename: .\Pages\Appointment.cshtml.cs
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.ComponentModel.DataAnnotations;

namespace RazorPagesBasics.Pages
{
public class AppointmentModel : PageModel
{
[BindProperty]
[Required(ErrorMessage = "Name cannot be left empty.")]
public string Name { get; set; }
[BindProperty]
[Required(ErrorMessage = "Age must be between 1 to 16.")]
[Range(1, 16, ErrorMessage = "Age must be between 1 to 16.")]
public int Age { get; set; }
[BindProperty]
public DateTime AppointmentDateTime
{ get; set; } = System.DateTime.Now;
[BindProperty]
public string Consult { get; set; }
[BindProperty]
public bool Fever { get; set; }
[BindProperty]
public bool Overseas { get; set; }
public string PatientInfo { get; set; }
public string DoctorInfo { get; set; }
public string ErrorMessage { get; set; }
public string strAppointmentDateTime { get; set; }
public IActionResult Onpost()
{
if (ModelState.IsValid)
{
strAppointmentDateTime = string.Format("{0:dd/MM/yyyy hh:mm tt}", AppointmentDateTime);
if (AppointmentDateTime < System.DateTime.Now.AddHours(3))
{
ErrorMessage = "Appointment Date/Time must be at least 3 hours in advance";
}
else
{
PatientInfo = Name + ", " + Age + " years";
if (Fever == true)
{
PatientInfo += ", Fever";
}
if (Overseas == true)
{
PatientInfo += ", Travelled overseas";
}

if (Consult == "Consultant")
{
DoctorInfo = "Consultant, $120.00";
}
else
{
DoctorInfo = "Senior Consultant, $200.00";
}
}

return Page();

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


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

}
else
{
return Page();
}
}
}
}

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

You might also like