Skip to content

Instantly share code, notes, and snippets.

View justintoth's full-sized avatar

Justin Toth justintoth

View GitHub Profile
function bindCategories(data) {
//ko.mapping.fromJS(data, mappingOptions, viewModel.cannedResponseCategoriesViewModel);
viewModel.cannedResponseCategoriesViewModel = ko.mapping.fromJS(data, mapping);
vjq.each(viewModel.cannedResponseCategoriesViewModel(), function (index, item) {
item.Label.subscribe(function (value) {
alert('subscribed');
Velaro.PremadeCategory.Update(ko.toJS(item));
});
subscribeInnerElements(item.Children);
function baseFormViewModel(entityName, list) {
var self = this;
this.baseInit = function () {
//set default values.
self.clear();
ko.applyBindings(self, $('#' + entityName + '-form-container')[0]);
//setup ajax form.
utils.setupForm(function (e) {
function mapJobFormViewModel(list) {
var self = new baseFormViewModel('job', list);
self.entity;
self.init = function () {
self.baseInit();
//setup datetime pickers.
$('#expectedArrivalDate').datetimepicker({
dateFormat: 'm/d/yy',
function mapJobListViewModel(details) {
var self = this;
this.entity;
this.views;
this.jobFormViewModel;
this.init = function () {
$('#job-date-range').change(function () {
self.get();
});
@justintoth
justintoth / WebRequestHelper.cs
Created April 16, 2013 19:15
Web Request Helper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Configuration;
using System.IO;
namespace Housters.Business.Utility.Helpers {
public static class WebRequestHelper {
@justintoth
justintoth / Balanced.cs
Created April 16, 2013 19:13
Balanced Schemas
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Housters.Schemas.Models.Account {
public class CreateAccountResponse {
public string bank_accounts_uri { get; set; }
public string cards_uri { get; set; }
public string created_at { get; set; }
@justintoth
justintoth / BalancedService.cs
Created April 16, 2013 19:13
Balanced Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using Newtonsoft.Json;
using Housters.Schemas.Models.Account;
using Housters.Business.Utility.Helpers;
using Housters.Schemas.Models.Accounting;
using Housters.Schemas.Models.Tenancy;
using Housters.Business.Services.Tenancy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using Newtonsoft.Json;
using Housters.Schemas.Models.Account;
using Housters.Business.Utility.Helpers;
using Housters.Schemas.Models.Accounting;
using Housters.Schemas.Models.Tenancy;
using Housters.Business.Services.Tenancy;
public static string PostWithAuth(string url, string requestBody = null, string method = "POST") {
using (WebClient client = new WebClient()) {
var credentials = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(APIKey + ":"));
client.Headers.Add(HttpRequestHeader.Authorization, credentials);
client.Headers.Add(HttpRequestHeader.Accept, "application/json");
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
client.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
return client.UploadString(url, method, !String.IsNullOrEmpty(requestBody) ? requestBody : "{}");
}
}
public static string PostWithAuth(string url, string requestBody = null, string method = "POST") {
using (WebClient client = new WebClient()) {
var credentials = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(APIKey + ":"));
client.Headers.Add(HttpRequestHeader.Authorization, credentials);
client.Headers.Add(HttpRequestHeader.Accept, "application/json");
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
client.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
if (!String.IsNullOrEmpty(requestBody))
return client.UploadString(url, method, requestBody);
else