-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed graph sample for Feb release
- Loading branch information
1 parent
f3065b2
commit c776d12
Showing
147 changed files
with
33,909 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Samples/MicrosoftGraph.Office365.Generic/OfficeDevPnP.MSGraphAPIDemo.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.23107.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OfficeDevPnP.MSGraphAPIDemo", "OfficeDevPnP.MSGraphAPIDemo\OfficeDevPnP.MSGraphAPIDemo.csproj", "{9A074D64-DB6A-4029-BF56-054A95250B58}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9A074D64-DB6A-4029-BF56-054A95250B58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9A074D64-DB6A-4029-BF56-054A95250B58}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9A074D64-DB6A-4029-BF56-054A95250B58}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9A074D64-DB6A-4029-BF56-054A95250B58}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+2.38 KB
Samples/MicrosoftGraph.Office365.Generic/OfficeDevPnP.MSGraphAPIDemo/AppIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions
32
...es/MicrosoftGraph.Office365.Generic/OfficeDevPnP.MSGraphAPIDemo/App_Start/BundleConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Web; | ||
using System.Web.Optimization; | ||
|
||
namespace OfficeDevPnP.MSGraphAPIDemo | ||
{ | ||
public class BundleConfig | ||
{ | ||
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 | ||
public static void RegisterBundles(BundleCollection bundles) | ||
{ | ||
bundles.Add(new ScriptBundle("~/bundles/jquery").Include( | ||
"~/Scripts/jquery-{version}.js")); | ||
|
||
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( | ||
"~/Scripts/jquery.validate*")); | ||
|
||
// Use the development version of Modernizr to develop with and learn from. Then, when you're | ||
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need. | ||
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( | ||
"~/Scripts/modernizr-*")); | ||
|
||
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( | ||
"~/Scripts/bootstrap.js", | ||
"~/Scripts/respond.js")); | ||
|
||
bundles.Add(new StyleBundle("~/Content/css").Include( | ||
"~/Content/bootstrap.css", | ||
"~/Content/Office365SuiteBar.css", | ||
"~/Content/site.css")); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...es/MicrosoftGraph.Office365.Generic/OfficeDevPnP.MSGraphAPIDemo/App_Start/FilterConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Web; | ||
using System.Web.Mvc; | ||
|
||
namespace OfficeDevPnP.MSGraphAPIDemo | ||
{ | ||
public class FilterConfig | ||
{ | ||
public static void RegisterGlobalFilters(GlobalFilterCollection filters) | ||
{ | ||
filters.Add(new HandleErrorAttribute()); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...les/MicrosoftGraph.Office365.Generic/OfficeDevPnP.MSGraphAPIDemo/App_Start/RouteConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using System.Web.Routing; | ||
|
||
namespace OfficeDevPnP.MSGraphAPIDemo | ||
{ | ||
public class RouteConfig | ||
{ | ||
public static void RegisterRoutes(RouteCollection routes) | ||
{ | ||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | ||
|
||
routes.MapRoute( | ||
name: "Default", | ||
url: "{controller}/{action}/{id}", | ||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } | ||
); | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...es/MicrosoftGraph.Office365.Generic/OfficeDevPnP.MSGraphAPIDemo/App_Start/Startup.Auth.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Web; | ||
using Owin; | ||
using Microsoft.Owin.Security; | ||
using Microsoft.Owin.Security.Cookies; | ||
using Microsoft.Owin.Security.OpenIdConnect; | ||
using Microsoft.IdentityModel.Clients.ActiveDirectory; | ||
using System.Threading.Tasks; | ||
using OfficeDevPnP.MSGraphAPIDemo.Components; | ||
using System.Security.Claims; | ||
|
||
namespace OfficeDevPnP.MSGraphAPIDemo | ||
{ | ||
public partial class Startup | ||
{ | ||
public void ConfigureAuth(IAppBuilder app) | ||
{ | ||
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); | ||
|
||
app.UseCookieAuthentication(new CookieAuthenticationOptions()); | ||
|
||
app.UseOpenIdConnectAuthentication( | ||
new OpenIdConnectAuthenticationOptions | ||
{ | ||
ClientId = MSGraphAPIDemoSettings.ClientId, | ||
Authority = MSGraphAPIDemoSettings.Authority, | ||
PostLogoutRedirectUri = MSGraphAPIDemoSettings.PostLogoutRedirectUri, | ||
Notifications = new OpenIdConnectAuthenticationNotifications() | ||
{ | ||
SecurityTokenValidated = (context) => | ||
{ | ||
return Task.FromResult(0); | ||
}, | ||
AuthorizationCodeReceived = (context) => | ||
{ | ||
var code = context.Code; | ||
|
||
ClientCredential credential = new ClientCredential( | ||
MSGraphAPIDemoSettings.ClientId, | ||
MSGraphAPIDemoSettings.ClientSecret); | ||
string signedInUserID = context.AuthenticationTicket.Identity.FindFirst( | ||
ClaimTypes.NameIdentifier).Value; | ||
|
||
AuthenticationContext authContext = new AuthenticationContext( | ||
MSGraphAPIDemoSettings.Authority, | ||
new SessionADALCache(signedInUserID)); | ||
AuthenticationResult result = authContext.AcquireTokenByAuthorizationCode( | ||
code, new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path)), | ||
credential, MSGraphAPIDemoSettings.MicrosoftGraphResourceId); | ||
|
||
return Task.FromResult(0); | ||
}, | ||
AuthenticationFailed = (context) => | ||
{ | ||
context.OwinContext.Response.Redirect("/Home/Error"); | ||
context.HandleResponse(); // Suppress the exception | ||
return Task.FromResult(0); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} |
209 changes: 209 additions & 0 deletions
209
...MicrosoftGraph.Office365.Generic/OfficeDevPnP.MSGraphAPIDemo/Components/CalendarHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
using Newtonsoft.Json; | ||
using OfficeDevPnP.MSGraphAPIDemo.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
|
||
namespace OfficeDevPnP.MSGraphAPIDemo.Components | ||
{ | ||
public static class CalendarHelper | ||
{ | ||
/// <summary> | ||
/// This method retrieves the calendars of the current user | ||
/// </summary> | ||
/// <param name="startIndex">The startIndex (0 based) of the items to retrieve, optional</param> | ||
/// <returns>A page of up to 10 calendars</returns> | ||
public static List<Calendar> ListCalendars(Int32 startIndex = 0) | ||
{ | ||
String jsonResponse = MicrosoftGraphHelper.MakeGetRequestForString( | ||
String.Format("{0}me/calendars?$skip={1}", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
startIndex)); | ||
|
||
var calendarList = JsonConvert.DeserializeObject<CalendarList>(jsonResponse); | ||
return (calendarList.Calendars); | ||
} | ||
|
||
/// <summary> | ||
/// This method retrieves the calendars of the current user | ||
/// </summary> | ||
/// <param name="id">The ID of the calendar</param> | ||
/// <returns>The calendar</returns> | ||
public static Calendar GetCalendar(String id) | ||
{ | ||
String jsonResponse = MicrosoftGraphHelper.MakeGetRequestForString( | ||
String.Format("{0}me/calendars/{1}", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
id)); | ||
|
||
var calendar = JsonConvert.DeserializeObject<Calendar>(jsonResponse); | ||
return (calendar); | ||
} | ||
|
||
/// <summary> | ||
/// This method retrieves the events of the current user's calendar | ||
/// </summary> | ||
/// <param name="calendarId">The ID of the calendar</param> | ||
/// <param name="startIndex">The startIndex (0 based) of the items to retrieve, optional</param> | ||
/// <returns>A page of up to 10 events</returns> | ||
public static List<Event> ListEvents(String calendarId, Int32 startIndex = 0) | ||
{ | ||
String jsonResponse = MicrosoftGraphHelper.MakeGetRequestForString( | ||
String.Format("{0}me/calendars/{1}/events?$skip={2}", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
calendarId, | ||
startIndex)); | ||
|
||
var eventList = JsonConvert.DeserializeObject<EventList>(jsonResponse); | ||
return (eventList.Events); | ||
} | ||
|
||
/// <summary> | ||
/// This method retrieves the events of the current user's calendar within a specific date range | ||
/// </summary> | ||
/// <param name="calendarId">The ID of the calendar</param> | ||
/// <param name="startDate">The start date of the range</param> | ||
/// <param name="endDate">The end date of the range</param> | ||
/// <param name="startIndex">The startIndex (0 based) of the items to retrieve, optional</param> | ||
/// <returns>A page of up to 10 events</returns> | ||
public static List<Event> ListEvents(String calendarId, DateTime startDate, | ||
DateTime endDate, Int32 startIndex = 0) | ||
{ | ||
String jsonResponse = MicrosoftGraphHelper.MakeGetRequestForString( | ||
String.Format("{0}me/calendars/{1}/calendarView?startDateTime={2:o}&endDateTime={3:o}&$skip={4}", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
calendarId, | ||
startDate.ToUniversalTime(), | ||
endDate.ToUniversalTime(), | ||
startIndex)); | ||
|
||
var eventList = JsonConvert.DeserializeObject<EventList>(jsonResponse); | ||
return (eventList.Events); | ||
} | ||
|
||
/// <summary> | ||
/// This method retrieves the events of a series within a specific date range | ||
/// </summary> | ||
/// <param name="calendarId">The ID of the calendar</param> | ||
/// <param name="masterSeriesId">The ID of the master event of the series</param> | ||
/// <param name="startDate">The start date of the range</param> | ||
/// <param name="endDate">The end date of the range</param> | ||
/// <param name="startIndex">The startIndex (0 based) of the items to retrieve, optional</param> | ||
/// <returns>A page of up to 10 events</returns> | ||
public static List<Event> ListSeriesInstances(String calendarId, | ||
String masterSeriesId, | ||
DateTime startDate, | ||
DateTime endDate, | ||
Int32 startIndex = 0) | ||
{ | ||
String jsonResponse = MicrosoftGraphHelper.MakeGetRequestForString( | ||
String.Format("{0}me/calendars/{1}/events/{2}/instances?startDateTime={3:o}&endDateTime={4:o}&$skip={5}", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
calendarId, | ||
masterSeriesId, | ||
startDate.ToUniversalTime(), | ||
endDate.ToUniversalTime(), | ||
startIndex)); | ||
|
||
var eventList = JsonConvert.DeserializeObject<EventList>(jsonResponse); | ||
return (eventList.Events); | ||
} | ||
|
||
/// <summary> | ||
/// This method creates an event in a target calendar | ||
/// </summary> | ||
/// <param name="calendarId">The ID of the target calendar</param> | ||
/// <param name="calendarEvent">The event to add</param> | ||
/// <returns>The added event</returns> | ||
public static Event CreateEvent(String calendarId, Event calendarEvent) | ||
{ | ||
String jsonResponse = MicrosoftGraphHelper.MakePostRequestForString( | ||
String.Format("{0}me/calendars/{1}/events", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
calendarId), | ||
calendarEvent, "application/json"); | ||
|
||
var createdEvent = JsonConvert.DeserializeObject<Event>(jsonResponse); | ||
return (createdEvent); | ||
} | ||
|
||
/// <summary> | ||
/// This method retrieves an event from a calendar | ||
/// </summary> | ||
/// <param name="calendarId">The ID of the calendar</param> | ||
/// <param name="eventId">The ID of the event</param> | ||
/// <returns>The retrieved event</returns> | ||
public static Event GetEvent(String calendarId, String eventId) | ||
{ | ||
String jsonResponse = MicrosoftGraphHelper.MakeGetRequestForString( | ||
String.Format("{0}me/calendars/{1}/events/{2}", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
calendarId, eventId)); | ||
|
||
var calendarEvent = JsonConvert.DeserializeObject<Event>(jsonResponse); | ||
return (calendarEvent); | ||
} | ||
|
||
/// <summary> | ||
/// This method updates an event in a calendar | ||
/// </summary> | ||
/// <param name="calendarId">The ID of the calendar</param> | ||
/// <param name="eventId">The event to update</param> | ||
/// <returns>The updated event</returns> | ||
public static Event UpdateEvent(String calendarId, Event eventToUpdate) | ||
{ | ||
String jsonResponse = MicrosoftGraphHelper.MakePatchRequestForString( | ||
String.Format("{0}me/calendars/{1}/events/{2}", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
calendarId, eventToUpdate.Id), | ||
eventToUpdate, "application/json"); | ||
|
||
var updatedEvent = JsonConvert.DeserializeObject<Event>(jsonResponse); | ||
return (updatedEvent); | ||
} | ||
|
||
/// <summary> | ||
/// This method deletes an event from a calendar | ||
/// </summary> | ||
/// <param name="calendarId">The ID of the calendar</param> | ||
/// <param name="eventId">The ID of the event to delete</param> | ||
public static void DeleteEvent(String calendarId, String eventId) | ||
{ | ||
MicrosoftGraphHelper.MakeDeleteRequest( | ||
String.Format("{0}me/calendars/{1}/events/{2}", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
calendarId, eventId)); | ||
} | ||
|
||
/// <summary> | ||
/// This method provides a feedback for a received meeting request | ||
/// </summary> | ||
/// <param name="calendarId">The ID of the calendar</param> | ||
/// <param name="eventId">The ID of the meeting request</param> | ||
/// <param name="feedback">The feedback for the meeting request</param> | ||
/// <param name="comment">Any comment to include in the feedback, optional</param> | ||
public static void SendFeedbackForMeetingRequest(String calendarId, | ||
String eventId, | ||
MeetingRequestFeedback feedback, | ||
String comment = null) | ||
{ | ||
MicrosoftGraphHelper.MakePostRequest( | ||
String.Format("{0}me/calendars/{1}/events/{2}/{3}", | ||
MicrosoftGraphHelper.MicrosoftGraphV1BaseUri, | ||
calendarId, eventId, feedback), | ||
content: !String.IsNullOrEmpty(comment) ? new { Comment = comment } : null, | ||
contentType: "application/json"); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Defines the possible feedbacks for a meeting request | ||
/// </summary> | ||
public enum MeetingRequestFeedback | ||
{ | ||
Accept, | ||
Decline, | ||
TentativelyAccept, | ||
} | ||
} |
Oops, something went wrong.