Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Various ways to output information from the HoursOfOperationModel
@model DEG.SC.HoursOfOperation.Web.Models.HoursOfOperationModel
@*Is the business open 24 hours a day?*@
@if (Model.OpenTwentyFourHours)
<div>Open 24 Hours!</div>
@*Various ways of accessing the days of the week*@
Monday: Open @Model[DayOfWeek.Monday].OpeningTime to @Model[DayOfWeek.Monday].ClosingTime
Tuesday: @(Model[DayOfWeek.Tuesday].IsClosed ? "Closed" : "Open")
@Model[DayOfWeek.Wednesday].DayOfWeek: Open @Model[DayOfWeek.Wednesday].OpeningTime to @Model[DayOfWeek.Wednesday].ClosingTime
@*Ability to loop through each day*@
@foreach (var day in Model.Days)
if (day.IsClosed)
<div>@day.DayOfWeek: Closed</div>
<div>@day.DayOfWeek: @day.OpeningTime to @day.ClosingTime</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment