Skip to content

Instantly share code, notes, and snippets.

View ChuckBryan's full-sized avatar

Chuck Bryan ChuckBryan

View GitHub Profile
/*Note: if you don't make the model Boolean, you will get errors on Create Actions where you might not initially new up a model.*/
@model Boolean?
<label>
@Html.CheckBox("", Model.HasValue && Model.Value) @ViewData.ModelMetadata.DisplayName
</label>
@model dynamic
@foreach (ModelMetadata prop in ViewData.ModelMetadata.Properties
.Where(p => p.ShowForEdit))
{
if (prop.TemplateHint == "HiddenInput")
{
@Html.Hidden(prop.PropertyName)
}
else
using System;
using System.Collections.Generic;
using Microsoft.Practices.ServiceLocation;
using StructureMap;
namespace StructureMap.ServiceLocatorAdapter {
public class StructureMapServiceLocator : ServiceLocatorImplBase {
private IContainer container;
public StructureMapServiceLocator(IContainer container) {
@model Boolean?
<div class="checkbox">
<label>
@Html.CheckBox("", Model.HasValue && Model.Value, new{ng_model = Html.AngularBindingForModel()}) @ViewData.ModelMetadata.DisplayName
</label>
</div>
@ChuckBryan
ChuckBryan / gist:47959f1bc2d1531318f4
Last active August 29, 2015 14:05
MVC Registry for Fail Tracker
public MvcRegistry(Func<IContainer> containerFactory)
{
For<BundleCollection>().Use(BundleTable.Bundles);
For<RouteCollection>().Use(RouteTable.Routes);
For<IIdentity>().Use(() => HttpContext.Current.User.Identity);
For<HttpSessionStateBase>()
.Use(() => new HttpSessionStateWrapper(HttpContext.Current.Session));
For<HttpContextBase>()
.Use(() => new HttpContextWrapper(HttpContext.Current));
For<HttpServerUtilityBase>()
@ChuckBryan
ChuckBryan / Datatables DOM element
Created November 1, 2014 12:01
My DataTables Bootstrap DOM element
dom: "<'row'<'col-xs-6'<'toolbar'>><'col-xs-6'l>>" +
"<'row'<'col-xs-12't>>" +
"<'row'<'col-xs-6'i><'col-xs-6'p>>",
@ChuckBryan
ChuckBryan / SeedDataConfig
Created November 2, 2014 13:42
SpecsFor SeedDataConfig with Entity Framework
using System;
using System.Data.Entity;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using SpecsFor.Mvc;
using SpecsForDemo.Web.Models;
namespace SpecsForDemo.IntegrationSpecs
{
public class SeedDataConfig : SpecsForMvcConfig
@ChuckBryan
ChuckBryan / Working Seed Data Config.
Created November 2, 2014 23:18
This is an example of the SeedData Class that I am using with SpecsFor.MVC.
using System;
using System.Data.Entity;
using Microsoft.AspNet.Identity;
using SpecsFor.Mvc;
using SpecsForDemo.Web.Models;
namespace SpecsForDemo.IntegrationSpecs
{
public class SeedDataConfig : SpecsForMvcConfig
{
@ChuckBryan
ChuckBryan / gist:0add618b984abfb8bfd4
Last active August 29, 2015 14:08
Setting up HTML Video Tag with SSL
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<video controls="controls" width="640" height="480" autoplay="autoplay">
<source src="Documents/Videos/BigBuckBunny_320x180.mp4" type="video/mp4" />
</video>
</body>
@ChuckBryan
ChuckBryan / RouteConfig.cs
Created September 21, 2017 16:50
Route Configuration for a Hybrid ASPNET/MVC project
namespace MyWebApp
{
using System.Web.Mvc;
using System.Web.Routing;
using Web.Infrastructure.Routing;
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{