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
window.accessToken = null; | |
window.tokenDefer = $.Deferred(); | |
var adLoginService = (function ($) { | |
$(document).ready(function () { | |
console.log("doc ready from AD Login"); | |
window.config = { | |
clientId: '<clientId of the azure AD app>', |
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
// | |
// The Client ID is used by the application to uniquely identify itself to Azure AD. | |
// The Tenant is the name of the Azure AD tenant in which this application is registered. | |
// The AAD Instance is the instance of Azure, for example public Azure or Azure China. | |
// The Redirect URI is the URI where Azure AD will return OAuth responses. | |
// The Authority is the sign-in URL of the tenant. | |
// | |
private static string aadInstance = ConfigurationManager.AppSettings["ida:AADInstance"]; | |
private static string tenant = ConfigurationManager.AppSettings["ida:Tenant"]; | |
private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"]; |
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
--1. get all indexes from current db, place in temp table | |
select | |
tablename = object_name(i.id), | |
tableid = i.id, | |
indexid = i.indid, | |
indexname = i.name, |
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
public class ADAuthorizeAttribute : System.Web.Http.AuthorizeAttribute | |
{ | |
static string aadInstance = ConfigurationManager.AppSettings["ida:AADInstance1"]; | |
static string tenant = ConfigurationManager.AppSettings["ida:Tenant"]; | |
static string audience = ConfigurationManager.AppSettings["ida:Audience"]; | |
string authority = String.Format(CultureInfo.InvariantCulture, aadInstance, tenant); | |
static string _issuer = string.Empty; | |
static List<SecurityToken> _signingTokens = null; |
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
public class ProductController : Controller | |
{ | |
private ProductService _productService; | |
// GET: Product | |
public async Task<ActionResult> Index() | |
{ | |
this._productService = new ProductService(); |
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
public static string GetProps<T>(Expression<Func<T, object>> parameters) | |
{ | |
StringBuilder requestedParametersString = new StringBuilder(); | |
if (parameters != null && parameters.Body != null) | |
{ | |
var body = parameters.Body as System.Linq.Expressions.NewExpression; | |
if (body.Members != null && body.Members.Any()) | |
{ | |
foreach (var member in body.Members) | |
{ |
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
public class ProductService | |
{ | |
private string BaseUrl { get; set; } | |
private HttpClient client { get; set; } | |
public ProductService() | |
{ | |
client = new HttpClient(); | |
BaseUrl = "http://myproductswebapi.azurewebsites.net/api/products"; |
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
// GET: Product | |
public async Task<ActionResult> Index() | |
{ | |
this._productService = new ProductService(); | |
var products = await this._productService.GetProducts(x => new { x.Id, x.Name, x.Price }); | |
return View("Products",products); | |
} | |
// GET: Product/Details/5 | |
public async Task<ActionResult> Details(int id) |
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
public class ShouldSerializeContractResolver : DefaultContractResolver | |
{ | |
protected override JsonProperty CreateProperty(System.Reflection.MemberInfo member, Newtonsoft.Json.MemberSerialization memberSerialization) | |
{ | |
var property = base.CreateProperty(member, memberSerialization); | |
if (property.DeclaringType == typeof(BaseEntity) || property.DeclaringType.BaseType == typeof(BaseEntity)) | |
{ | |
if (property.PropertyName == "serializableProperties") | |
{ |
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
// GET api/products/5 | |
public JsonResult<Product> Get(int id, string fields="") | |
{ | |
var product = _productsRepository.Find(x => x.Id == id); | |
product.SetSerializableProperties(fields); | |
return Json(product, new Newtonsoft.Json.JsonSerializerSettings() | |
{ | |
ContractResolver = new ShouldSerializeContractResolver() | |
}); | |
} |
NewerOlder