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
[Route("api/user/{id}")] | |
public virtual HttpResponseMessage Post(User user) | |
{ | |
if (!ModelState.IsValid) | |
{ | |
return Request.CreateResponse(HttpStatusCode.BadRequest); | |
} | |
Session.SaveOrUpdate(user); |
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
requirejs.config({ | |
paths: { | |
'text': '../Scripts/text', | |
'durandal': '../Scripts/durandal', | |
'plugins': '../Scripts/durandal/plugins', | |
'transitions': '../Scripts/durandal/transitions' | |
} | |
}); | |
define('jquery', function() { return jQuery; }); |
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 DurandalViewController : Controller | |
{ | |
// | |
// GET: /App/views/{viewName}.cshtml | |
[HttpGet] | |
public ActionResult Get(string viewName) | |
{ | |
return View("~/App/views/" + viewName + ".cshtml"); | |
} | |
} |
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
routes.MapRoute( | |
name: "Durandal App Views", | |
url: "App/views/{viewName}.cshtml", | |
defaults: new { controller = "DurandalView", action = "Get" } | |
); |
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
var name = ko.observable('Bert'); | |
var upperCaseName = ko.computed(function() { | |
return name().toUpperCase(); | |
}); |
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
function AppViewModel() { | |
var self = this; | |
self.firstName = ko.observable('Bob'); | |
self.lastName = ko.observable('Smith'); | |
self.hasChanges = ko.computed(function() { | |
ko.toJSON(self); | |
console.log("changed"); |
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
var name = ko.observable('Bart').extend({ rateLimit: 500 }); | |
//Name will only change to uppercase after 0.5 seconds | |
var upperCaseName = ko.computed(function() { | |
return name().toUpperCase(); | |
}); | |
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
<handlers> | |
<add name="HtmlFileHandler" path="*.html" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/> | |
</handlers> |
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
routes.MapRoute( | |
name: "Durandal App Views", | |
url: "App/features/{viewName}.html", | |
defaults: new { controller = "DurandalView", action = "Get" } | |
); |
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
function locationHashChanged() { | |
//if Google Analytics is available, then push the current location | |
if (_gaq !== undefined) { | |
_gaq.push(['_trackPageview', path]); | |
} | |
} | |
window.onhashchange = locationHashChanged; |