Skip to content

Instantly share code, notes, and snippets.

@bruceharrison1984
Last active August 30, 2019 15:40
Show Gist options
  • Save bruceharrison1984/3c7e3e47c572167d9e6a33185837d434 to your computer and use it in GitHub Desktop.
Save bruceharrison1984/3c7e3e47c572167d9e6a33185837d434 to your computer and use it in GitHub Desktop.
public class Widgets
{
private readonly DbContext _DbContext;
private readonly FunctionWrapper _functionWrapper;
public Widgets(DbContext DbContext, FunctionWrapper functionWrapper)
{
_DbContext = DbContext;
_functionWrapper = functionWrapper;
}
[FunctionName("GetWidget")]
public async Task<IActionResult> GetWidget([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "/widgets/{id}")] HttpRequest req, int id, ILogger log)
{
return await _functionWrapper.Execute(async () =>
{
log.LogInformation($"getting widget: ${id}");
var selectedItem = await _DbContext.Widgets.FindAsync(id);
return new CustomObjectResult(selectedItem, StatusCodes.Status200OK);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment