Skip to content

Instantly share code, notes, and snippets.

@khalidabuhakmeh
Created May 22, 2018 19:34
Show Gist options
  • Select an option

  • Save khalidabuhakmeh/4403cdcf82df88b9d132c257b71457a4 to your computer and use it in GitHub Desktop.

Select an option

Save khalidabuhakmeh/4403cdcf82df88b9d132c257b71457a4 to your computer and use it in GitHub Desktop.
public controller Home {
// GET home/something
GET Something() {
// c# code here
// assumes you are returning IActionResult
return Ok();
}
// POST home/something
POST Something(Model Model) {
// c# code here
// assumes you are returning IActionResult
return Ok();
}
// GET home/greetings
async GET Greetings(HttpRequest request) {
var result = await Task.FromResult(0);
return Ok(result);
}
// POST Homes/{id}
// convention dictates anything not in
// a complex model is a path parameter
async POST Homes(int id, HomeRequest request) {
var home = db.Homes.Find(id);
home.Update(request);
return home;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment