Skip to content

Commit

Permalink
Updates to provide a partner a sample app
Browse files Browse the repository at this point in the history
Updates to Calendar view, and removed "Contact Us" and "About" sections.
  • Loading branch information
VenkatAyyadevara-MSFT committed Jan 22, 2016
1 parent 41f3255 commit 86e253c
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 64 deletions.
12 changes: 4 additions & 8 deletions dotnet-tutorial/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,14 @@ public async Task<ActionResult> Calendar()

client.Context.SendingRequest2 += new EventHandler<Microsoft.OData.Client.SendingRequest2EventArgs>(
(sender, e) => InsertXAnchorMailboxHeader(sender, e, email));

/** var eventResults = await client.Me.Events
.OrderByDescending(e => e.Start.DateTime)
.Take(10)
.Select(e => new Models.DisplayEvent(e.Subject, e.Start.DateTime, e.End.DateTime))
.ExecuteAsync(); */

// Use calendar view to get meetings for the next N hours
var startDateTime = new DateTimeOffset(DateTime.Now);
var endDateTime = new DateTimeOffset(DateTime.Now.AddHours(+3));
var endDateTime = new DateTimeOffset(DateTime.Now.AddHours(+12));
var eventResults = await client.Me.GetCalendarView(startDateTime, endDateTime)
.OrderByDescending(e => e.Start.DateTime)
.Take(10)
.Select(e => new Models.DisplayEvent(e.Subject, e.Start.DateTime, e.End.DateTime))
.Select(e => new Models.DisplayEvent(e.Subject, e.Start.DateTime, e.End.DateTime, e.Location, e.Organizer))
.ExecuteAsync();

return View(eventResults.CurrentPage);
Expand Down
49 changes: 47 additions & 2 deletions dotnet-tutorial/Models/DisplayEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,65 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Office365.OutlookServices;

namespace dotnet_tutorial.Models
{
public class DisplayEvent
{
public string Subject { get; set; }
public string Organizer { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }

public DisplayEvent(string subject, string start, string end)
public string LocationDisplayName { get; set; }
public string LocationAddress { get; set; }
public string LocationCoordinates { get; set; }

public DisplayEvent(string subject, string start, string end, Location location, Recipient organizer)
{
this.Subject = subject;
this.Organizer = BuildOrganizerString(organizer);
this.Start = DateTime.Parse(start);
this.End = DateTime.Parse(end);
this.LocationDisplayName = location.DisplayName ?? "null";
this.LocationAddress = BuildAddressString(location.Address);
this.LocationCoordinates = BuildCoordinatesString(location.Coordinates);
}

public String BuildOrganizerString(Recipient organizer)
{
return String.Format("{0} <{1}>",
organizer.EmailAddress.Name ?? "<No Name>",
organizer.EmailAddress.Address
);
}

public String BuildAddressString(PhysicalAddress address)
{
if (address == null)
{
return "null";
}
else {
return String.Format("{0}, {1}, {2}, {3}",
address.Street == "" ? "<No Street>" : address.Street,
address.City == "" ? "<No City>" : address.City,
address.State == "" ? "<No State>" : address.State,
address.CountryOrRegion == "" ? "<No Country Or Region>" : address.CountryOrRegion
);
}
}

public String BuildCoordinatesString(GeoCoordinates coordinates)
{
if (coordinates == null)
{
return "null";
}
else
{
return String.Format("{0}, {1}", coordinates.Latitude, coordinates.Longitude);
}
}
}
}
7 changes: 0 additions & 7 deletions dotnet-tutorial/Views/Home/About.cshtml

This file was deleted.

28 changes: 22 additions & 6 deletions dotnet-tutorial/Views/Home/Calendar.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,29 @@

<h2>Calendar</h2>

<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Subject)
</th>
<th>
@Html.DisplayNameFor(model => model.Organizer)
</th>
<th>
@Html.DisplayNameFor(model => model.Start)
</th>
<th>
@Html.DisplayNameFor(model => model.End)
</th>
<th>
@Html.DisplayNameFor(model => model.LocationDisplayName)
</th>
<th>
@Html.DisplayNameFor(model => model.LocationAddress)
</th>
<th>
@Html.DisplayNameFor(model => model.LocationCoordinates)
</th>
<th></th>
</tr>

Expand All @@ -28,16 +37,23 @@
<td>
@Html.DisplayFor(modelItem => item.Subject)
</td>
<td>
@Html.DisplayFor(modelItem => item.Organizer)
</td>
<td>
@Html.DisplayFor(modelItem => item.Start)
</td>
<td>
@Html.DisplayFor(modelItem => item.End)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
@Html.DisplayFor(modelItem => item.LocationDisplayName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LocationAddress)
</td>
<td>
@Html.DisplayFor(modelItem => item.LocationCoordinates)
</td>
</tr>
}
Expand Down
17 changes: 0 additions & 17 deletions dotnet-tutorial/Views/Home/Contact.cshtml

This file was deleted.

8 changes: 0 additions & 8 deletions dotnet-tutorial/Views/Home/Contacts.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

<h2>Contacts</h2>

<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
Expand All @@ -34,11 +31,6 @@
<td>
@Html.DisplayFor(modelItem => item.MobilePhone)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}

Expand Down
8 changes: 0 additions & 8 deletions dotnet-tutorial/Views/Home/Inbox.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

<h2>Inbox</h2>

<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
Expand All @@ -35,11 +32,6 @@
<td>
@Html.DisplayFor(modelItem => item.From)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}

Expand Down
4 changes: 2 additions & 2 deletions dotnet-tutorial/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
}

<div class="jumbotron">
<h1>ASP.NET MVC Tutorial</h1>
<p class="lead">This sample app uses the Mail API to read messages in your inbox.</p>
<h1>Outlook REST API ASP.NET MVC Tutorial</h1>
<p class="lead">This sample app uses the Outlook REST API to read messages in your inbox, read events from your calendar, or read personal contacts.</p>
<p><a href="@Url.Action("SignIn", "Home", null, Request.Url.Scheme)" class="btn btn-primary btn-lg">Click here to login</a></p>
</div>

Expand Down
8 changes: 4 additions & 4 deletions dotnet-tutorial/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
@Html.ActionLink("Sample App", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
<li>@Html.ActionLink("Inbox", "Index", "Home")</li>
<li>@Html.ActionLink("Calendar", "Calendar", "Home")</li>
<li>@Html.ActionLink("Contacts", "Contacts", "Home")</li>
</ul>
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions dotnet-tutorial/dotnet-tutorial.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@
<Content Include="Views\_ViewStart.cshtml" />
<Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
<Content Include="Views\Home\About.cshtml" />
<Content Include="Views\Home\Contact.cshtml" />
<Content Include="Views\Home\Index.cshtml" />
<Content Include="Views\Home\Inbox.cshtml" />
<Content Include="Views\Home\Calendar.cshtml" />
Expand Down

0 comments on commit 86e253c

Please sign in to comment.