Skip to content

Instantly share code, notes, and snippets.

@ryanvgates
ryanvgates / web.config
Created June 1, 2015 22:25
SharePoint - aspnet:AllowAnonymousImpersonation
<configuration>
<appSettings>
<add key="aspnet:AllowAnonymousImpersonation" value="false" />
</appSettings>
</configuration>
@ryanvgates
ryanvgates / Validation.cs
Last active August 29, 2015 14:26
Validation Logic
public override IEnumerable<RuleViolation> GetRuleViolations(int orgID)
{
if (string.IsNullOrEmpty(FirstName))
yield return new RuleViolation("First Name required", "FirstName");
if (string.IsNullOrEmpty(LastName))
yield return new RuleViolation("Last Name required", "LastName");
if (string.IsNullOrEmpty(Name))
yield return new RuleViolation("Name required", "Name");
if (string.IsNullOrEmpty(Phone))
yield return new RuleViolation("Phone required", "Phone");
@ryanvgates
ryanvgates / OrgVM.cs
Last active August 29, 2015 14:26
Correct Model
public class OrgVM
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
}
@ryanvgates
ryanvgates / OrgVM.cs
Created August 1, 2015 05:06
Incorrect Model
public class OrgVM
{
public string Name { get; set; }
public string Phone { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
<%if(!ViewData.ModelState.IsValid) { %>
<div id="save-fail">
<%= Html.ValidationSummary("Please correct the errors and try again.") %>
</div>
<%} %>
<% using (Html.BeginForm("Create", "OrgSetup", FormMethod.Post)){%>
<p class="floatLabel"><label for="FirstName">First Name</label></p>
<p><label for="LastName">Last Name</label></p>
@ryanvgates
ryanvgates / TFS.psm1
Last active September 16, 2016 04:06
TFS PSM
#
# TFS.psm1
#
Function QueueBuilds {
param($serverName, $teamProject, [string[]]$buildDefinitionNames)
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")
@ryanvgates
ryanvgates / Queue.Dev.Builds.ps1
Last active September 23, 2015 01:43
Queue Development Builds
#
# Queue Dev Builds
#
Import-Module $PSScriptRoot\TFS\TFS.psm1
$buildNames =
"Service1 - Continuous",
"Service1.DB - Continuous",
"Service2 - Continuous",
@ryanvgates
ryanvgates / CallbackController.cs
Last active September 24, 2015 15:43
IdentityServer3 Prototype IdServer Startup
[HttpPost]
[ActionName("Index")]
public async Task<ActionResult> GetToken()
{
var client = new TokenClient(
"https://localhost:44333/connect/token",
"AuthCode",
"secret");
var code = Request.QueryString["code"];
@ryanvgates
ryanvgates / Package Manager Console
Last active November 4, 2015 04:51
Nuget Update-Package Gotcha
PM> update-package FluentValidation
Attempting to gather dependencies information for multiple packages with respect to project 'solution\project', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for multiple packages
update-package : Unable to find package 'IdentityManager'. Existing packages must be restored before performing an install or update.
At line:1 char:1
+ update-package FluentValidation
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
@ryanvgates
ryanvgates / Works
Created November 4, 2015 04:50
Nuget Update-Package Gotcha Works
Update-Package FluentValidation -Pre