Last active
December 23, 2015 13:28
-
-
Save beyond-code-github/6641906 to your computer and use it in GitHub Desktop.
Model binding and returning a custom status code
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
namespace WebApiModuleHelloWorld | |
{ | |
using System.Net; | |
public class Product | |
{ | |
public string Name { get; set; } | |
public double Price { get; set; } | |
} | |
public class HelloWorldModule : Superscribe.WebApi.Modules.SuperscribeModule | |
{ | |
public HelloWorldModule() | |
{ | |
this.Get["/"] = _ => "Hello World!"; | |
this.Get["Products" / (ʃLong)"Id"] = _ => { throw new NotImplementedException(); }; | |
this.Post["Products"] = _ => | |
{ | |
var product = _.Bind<Product>(); | |
// Save product | |
return HttpStatusCode.Created; | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment