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 IHandleRequestsForRoles : ActionSelectorMethodAttribute | |
{ | |
public string Roles { get; set; } | |
public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) | |
{ | |
var roles = Roles.GetRolesForUser(); | |
var segments = this.Roles.Split(','); | |
bool isValidForRequest = false; |
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 UsersController : ApplicationController // base class exposes profiler, etc. | |
{ | |
[Authorize(Roles = Roles.Administrator)] | |
[Authorize(Roles = Roles.Owner)] | |
public ActionResult Register() | |
{ | |
return View(); | |
} | |
[HttpPost] |
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 interface IReplayCommits | |
{ | |
void Replay(DateTime start); | |
void Replay(Guid streamId, int minRevision, int maxRevision); | |
} |
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
/// <summary> | |
/// Represents a monetary amount for a given currency. | |
/// Allows easy representation and conversion of monetary values. | |
/// </summary> | |
public class Money | |
{ | |
/// <summary> | |
/// Amount of money | |
/// </summary> | |
public readonly decimal Amount; |
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 Money | |
{ | |
public readonly decimal Amount; | |
public readonly string CurrencyCode; | |
public Money(decimal amount) | |
: this(amount, "en-us") | |
{ } | |
public Money(decimal amount, string currencyCode) |
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 Calculator | |
{ | |
public static int Add(IEnumerable<int> operands) | |
{ | |
return operands.Sum(); | |
} | |
} |
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 void Main() | |
{ | |
while(true) { | |
Console.WriteLine("Provide 2 numbers and I'll add them for you!"); | |
var input = Console.ReadLine(); | |
if(!string.IsNullOrEmpty(input)) | |
{ | |
var segments = input.Split(' '); |
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 ConnectionFactory | |
{ | |
public static IDbConnection Create() | |
{ | |
var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["default"].ConnectionString); | |
connection.Open(); | |
return new ProfiledDbConnection(connection, MiniProfiler.Current); | |
} | |
} |
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
-- Designation Table Structure | |
Id | |
Name | |
Route | |
-- Many To Many Relationship | |
DesignationId | |
CommunityId | |
-- Community Table Structure |
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 BaseController : Controller | |
{ | |
// auto-populate this based on request | |
public Directory Directory { get; set; } | |
} | |
public class AnotherController : BaseController | |
{ | |
public ActionResult Index() | |
{ |