Skip to content

Instantly share code, notes, and snippets.

View andrewconnell's full-sized avatar
📺
Building courses for @Voitanos

Andrew Connell andrewconnell

📺
Building courses for @Voitanos
View GitHub Profile
@andrewconnell
andrewconnell / SPRestCall-SPTaskJson.cs
Created December 9, 2014 02:02
XML vs. JSON Serialization in Server Side Code - Snippet 3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
namespace TasksWeb.Models {
public class SpTaskJsonCollection {
[JsonProperty(PropertyName = "d")]
public DataCollectionReponse Data { get; set; }
@andrewconnell
andrewconnell / SPRestCall-Json.cs
Created December 9, 2014 02:05
XML vs. JSON Serialization in Server Side Code - Snippet 4
var spTaskJsonResponse = JsonConvert.DeserializeObject<SpTaskJsonCollection>(responseString);
List<SpTask> tasks = new List<SpTask>();
foreach (var spListitem in spTaskJsonResponse.Data.Results) {
SpTask task = new SpTask {
Id = spListitem.Id.ToString(),
Title = spListitem.Title,
Status = spListitem.Status,
Priority = spListitem.Priority
};
@andrewconnell
andrewconnell / PerUserWebCache.cs
Created December 17, 2014 15:21
Azure AD & ASP.NET MVC - Walk-Through Implementing ADAL & OWIN - PerUserWebCache.cs
using System;
using System.ComponentModel.DataAnnotations;
namespace SampleMvcAzAuth.Models {
public class PerUserWebCache {
[Key]
public int EntryId { get; set; }
public string WebUserUniqueId { get; set; }
public byte[] CacheBits { get; set; }
public DateTime LastWrite { get; set; }
@andrewconnell
andrewconnell / TokenCacheDataContext.cs
Created December 17, 2014 15:24
Azure AD & ASP.NET MVC - Walk-Through Implementing ADAL & OWIN - TokenCacheDataContext.cs
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using SampleMvcAzAuth.Models;
namespace SampleMvcAzAuth.Data {
public class TokenCacheDataContext : DbContext{
public TokenCacheDataContext()
: base("TokenCacheDataContext") { }
public DbSet<PerUserWebCache> PerUserCacheList { get; set; }
@andrewconnell
andrewconnell / TokenCacheInitializer.cs
Created December 17, 2014 15:25
Azure AD & ASP.NET MVC - Walk-Through Implementing ADAL & OWIN - TokenCacheInitializer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SampleMvcAzAuth.Data {
public class TokenCacheInitializer : System.Data.Entity.DropCreateDatabaseIfModelChanges<TokenCacheDataContext>
{
}
}
@andrewconnell
andrewconnell / SettingsHelper.cs
Created December 17, 2014 15:33
Azure AD & ASP.NET MVC - Walk-Through Implementing ADAL & OWIN - SettingsHelper.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
namespace SampleMvcAzAuth.Utils {
public class SettingsHelper {
public static string ClientId {
get { return ConfigurationManager.AppSettings["ida:ClientID"]; }
@andrewconnell
andrewconnell / EfAdalTokenCache.cs
Created December 17, 2014 15:38
Azure AD & ASP.NET MVC - Walk-Through Implementing ADAL & OWIN - EfAdalTokenCache.cs
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Caching;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using SampleMvcAzAuth.Data;
using SampleMvcAzAuth.Models;
@andrewconnell
andrewconnell / Startup.cs
Created December 17, 2014 15:42
Azure AD & ASP.NET MVC - Walk-Through Implementing ADAL & OWIN - Startup.cs
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(SampleMvcAzAuth.Startup))]
namespace SampleMvcAzAuth {
public partial class Startup {
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
@andrewconnell
andrewconnell / Startup.Auth.cs
Created December 17, 2014 15:43
Azure AD & ASP.NET MVC - Walk-Through Implementing ADAL & OWIN - Startup.Auth.cs
using System;
using System.Threading.Tasks;
using System.Web;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;
using Owin;
using SampleMvcAzAuth.Utils;
@andrewconnell
andrewconnell / AccountController.cs
Created December 17, 2014 15:48
Azure AD & ASP.NET MVC - Walk-Through Implementing ADAL & OWIN - AccountController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Web;
using System.Web.Mvc;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;