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
// Ref: http://odetocode.com/Articles/739.aspx | |
// Using LINQ to simplify business rules | |
Employee employee = | |
new Employee { ID = 1, Name = | |
"Poonam", DepartmentID = 1 }; | |
Func<Employee, bool>[] validEmployeeRules = | |
{ | |
e => e.DepartmentID > 0, |
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
// NOTE: Build a url with query params | |
angular.module('app').factory('UrlBuilder', function () { | |
function sortedKeys(obj) { | |
var keys = []; | |
for (var key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
keys.push(key); | |
} | |
} |
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
// Ref: http://stackoverflow.com/questions/3738748/create-an-array-or-list-of-all-dates-between-two-dates | |
void Main() | |
{ | |
var requirements = GetRequirements(); | |
// TODO: Add a margin at the start and end | |
// Get a range of dates | |
var start = requirements.Select (x =>x.DtFm).Min(); | |
var end =requirements.Select (x =>x.DtTo).Max(); | |
var dateRange = Enumerable.Range(0, 1 + end.Subtract(start).Days) |
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
// Format as per flot requirements | |
var flotData = new[] | |
{ | |
new {label = "Quantity Required", data = partAvailability.Select(x => new[] {x.TimeStamp, x.QuantityRequired})}, | |
new {label = "Quantity Available", data = partAvailability.Select(x => new[] {x.TimeStamp, x.QuantityAvailable})} | |
}; | |
// Timestamp created as follows | |
private static long GetJavascriptTimestamp(DateTime date) | |
{ |
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
// Ref: [mythz](https://groups.google.com/forum/#!topic/servicestack/bb95kGpDcEo) | |
using System; | |
using System.Configuration; | |
using System.Data; | |
using System.Data.Common; | |
namespace Clear2Pay.OTS.UTP.Data.Tests | |
{ | |
public class Database : IDisposable | |
{ |
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
using System; | |
using System.Data; | |
using Dapper; | |
using Dapper.Contrib.Extensions; | |
using NUnit.Framework; | |
using ServiceStack.Text; | |
//using Dommel; | |
namespace DataAccess |
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
// This is a module for cloud persistance in mongolab - https://mongolab.com | |
angular.module('mongolab', ['ngResource']). | |
factory('Project', function($resource) { | |
var Project = $resource('https://api.mongolab.com/api/1/databases' + '/cars/collections/projects/:id', { | |
apiKey: '4f99a253e4b015f77d298ab8' | |
}, { | |
update: { | |
method: 'PUT' | |
} | |
}); |
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
angular.module('formComponents', []) | |
.directive('formInput', function() { | |
return { | |
restrict: 'E', | |
scope: {}, | |
link: function(scope, element, attrs) | |
{ | |
var type = attrs.type || 'text'; | |
var required = attrs.hasOwnProperty('required') ? "required='required'" : ""; | |
var htmlText = '<div class="control-group">' + |
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
// This is a module for cloud persistance in mongolab - https://mongolab.com | |
angular.module('mongolab', ['ngResource']). | |
factory('Project', function($resource) { | |
var Project = $resource('https://api.mongolab.com/api/1/databases' + | |
'/angularjs/collections/projects/:id', | |
{ apiKey: '4f847ad3e4b08a2eed5f3b54' }, { | |
update: { method: 'PUT' } | |
} | |
); | |
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
angular.module('project', ['mongolab']). | |
config(function($routeProvider) { | |
$routeProvider. | |
when('/', {controller:ListCtrl, templateUrl:'list.html'}). | |
when('/edit/:projectId', {controller:EditCtrl, templateUrl:'detail.html'}). | |
when('/new', {controller:CreateCtrl, templateUrl:'detail.html'}). | |
otherwise({redirectTo:'/'}); | |
}); | |
OlderNewer