Skip to content

Instantly share code, notes, and snippets.

// Verify if a datetime is in a range
public static bool BetweenInclusive(this DateTime dateToCompare,
DateTime Left, DateTime Right)
{
bool result = (dateToCompare.CompareTo(Left) >= 0) &&
(dateToCompare.CompareTo(Right) <= 0);
return result;
}
// Verify if a datetime is in a range
private const string As400TimestampMask = "yyyy-MM-dd-HH.mm.ss.sss";
private const string As400TimeMask = "hh:mm:ss";
private const string As400DateMask = "yyyy-MM-dd";
http://jsfiddle.net/n8fw5m4L/
@christopherbauer
christopherbauer / ISelectable.cs
Created July 16, 2015 16:42
SelectListFactory examples for blog
public interface ISelectable
{
string GetValueField();
string GetTextField();
}
@christopherbauer
christopherbauer / DateRange.cs
Created July 23, 2015 11:38
DateRange DDD Model
public struct DateRange
{
public DateRange(DateTime start, DateTime end)
: this()
{
if (start > end)
{
throw new ArgumentException("Start date time cannot be after end date time");
}
Start = start;
@christopherbauer
christopherbauer / DateRangeTests.cs
Last active August 29, 2015 14:26
BLOG - Date Range Tests
public class DateRangeTests
{
[TestFixture]
public class when_instantiating_date_ranges
{
[Test]
public void then_should_set_start_date_given_start_date()
{
// Arrange // Act
@christopherbauer
christopherbauer / DateRange.cs
Last active August 29, 2015 14:26
Blog - Date Range
public struct DateRange
{
private readonly DateTime _start;
private readonly DateTime _end;
public DateRange(DateTime start, DateTime end)
: this()
{
if (start > end)
{
@christopherbauer
christopherbauer / AtLeastOneAttribute.cs
Created July 29, 2015 18:30
AtLeastOne Attribute and Validator Implementation for MVC 3+ (Note: only validates client-side)
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class AtLeastOneAttribute : ValidationAttribute, IClientValidatable
{
public string GroupName { get; private set; }
public AtLeastOneAttribute(string groupName)
{
GroupName = groupName;
}
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
Import-Module WebAdministration
if ($OctopusParameters -eq $null)
{
$OctopusParameters = @{
OctopusWebSiteName = "Default Web Site\SiteName"
ApplicationPoolName = "AppPoolName"
UseCustomAppPoolUser = false
};
}
@christopherbauer
christopherbauer / IApiRequestor.cs
Last active August 29, 2015 14:27
Api Requestor
public interface IApiRequester
{
Task<TResult> PostAsyncResult<TResult>(Uri uri, object data) where TResult : class;
Task<TResult> GetAsyncResult<TResult>(Uri uri) where TResult : class;
}