Last active
August 30, 2019 15:40
-
-
Save bruceharrison1984/3c7e3e47c572167d9e6a33185837d434 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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