title: How to fix that a user should not be able to book a time that has passed
body: <p>I'm working on a school project right now, and we are building a booking system which displays available times for only today. (We're not using a calendar). My question is how do I only display available hours for today and not display the passed hours? Right now the code displays all the times from 8.00 to 16.00 even if the real time is 12.00. If the clock is 12 I would only like to display the hours after 12. I hope that you can help me, because I haven't found a solution that suits me.</p>
  
  <p>This is how the code looks like in the View:</p>
  
  <pre><code>@{
      int open = 8;
      decimal inHours = Convert.ToDecimal(Model.service.Duration) / Convert.ToDecimal(60);
      int iterations = (int)Math.Floor(Convert.ToDecimal(open) / Convert.ToDecimal(inHours));
      DateTime startTime = DateTime.Today;
      startTime = startTime.AddHours(8);
  
      List&lt;DateTime&gt; dt = new List&lt;DateTime&gt;();
      for (int i = 0; i &lt; iterations; i++) 
      {
          DateTime endTime = startTime;
          endTime = endTime.AddMinutes(Model.service.Duration);
          if (!Model.service.Bookings.Any(x =&gt; x.StartTime == startTime)) 
          {
              @Html.ActionLink(startTime.ToString("HH:mm") + "-" + endTime.ToString("HH:mm"),  
                  "BookService", "Booking", new 
                      { 
                          inBookingSystemId = Model.bookingSystem.BookingSystemId, 
                          inServiceId = Model.service.ServiceId, 
                          inStartTime = startTime.ToString() 
                       }, new { @class = "btn btn-primary" })
          }
          startTime = endTime;
      }
  }
  </code></pre>