Index: Calendar.ASP.NET.MVC5/Views/Calendar/UpcomingEvents.cshtml |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/Calendar.ASP.NET.MVC5/Views/Calendar/UpcomingEvents.cshtml |
@@ -0,0 +1,81 @@ |
+@* |
+Copyright 2015 Google Inc |
+ |
+Licensed under the Apache License, Version 2.0(the "License"); |
+you may not use this file except in compliance with the License. |
+You may obtain a copy of the License at |
+ |
+ http://www.apache.org/licenses/LICENSE-2.0 |
+ |
+Unless required by applicable law or agreed to in writing, software |
+distributed under the License is distributed on an "AS IS" BASIS, |
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+See the License for the specific language governing permissions and |
+limitations under the License. |
+*@ |
+ |
+@model Calendar.ASP.NET.MVC5.Models.UpcomingEventsViewModel |
+@using CalendarData = Google.Apis.Calendar.v3.Data; |
+ |
+@{ |
+ ViewBag.Title = "Upcoming Events"; |
+} |
+ |
+@helper FormatEventTime(CalendarData.EventDateTime when) |
+{ |
+ // Either Date or DateTime is set, depending on whether or not the event is |
+ // an all-day event. |
+ if (when.DateTime == null) |
+ { |
+ <text>All day</text> |
+ } |
+ else |
+ { |
+ @:@when.DateTime.Value.ToShortTimeString() |
+ } |
+} |
+@helper FormatEventLength(CalendarData.EventDateTime start, CalendarData.EventDateTime end) |
+{ |
+ var duration = end.DateTime - start.DateTime; |
+ if (duration == null) |
+ { |
+ <text>All day</text> |
+ } |
+ else |
+ { |
+ @:@string.Format( |
+ "{0} hour{1} {2} minute{3}", |
+ (int)duration.Value.TotalHours, |
+ duration.Value.TotalHours >= 2 ? "s" : "", |
+ (int)duration.Value.Minutes, |
+ duration.Value.Minutes >= 2 ? "s" : "") |
+ } |
+} |
+ |
+<h2>Upcoming Events</h2> |
+ |
+<table class="table"> |
+ <thead> |
+ <tr> |
+ <th>Time</th> |
+ <th>Length</th> |
+ <th>Summary</th> |
+ </tr> |
+ </thead> |
+ |
+@foreach (var group in Model.EventGroups) |
+{ |
+ <tbody> |
+ <tr><th colspan="4">@group.GroupTitle</th></tr> |
+ @foreach (var item in group.Events) |
+ { |
+ <tr> |
+ <td>@FormatEventTime(item.Start)</td> |
+ <td>@FormatEventLength(item.Start, item.End)</td> |
+ <td>@item.Summary</td> |
+ </tr> |
+ } |
+ </tbody> |
+} |
+ |
+</table> |