Skip to content

Instantly share code, notes, and snippets.

@joncloud
Created January 5, 2017 16:53
Show Gist options
  • Select an option

  • Save joncloud/61e0a50134b226aa14c7b5755bd0069e to your computer and use it in GitHub Desktop.

Select an option

Save joncloud/61e0a50134b226aa14c7b5755bd0069e to your computer and use it in GitHub Desktop.
ASP.NET Core Services
[Route("api/applications")]
public class ApplicationsController : Controller
{
private IApplicationService applicationService;
public ApplicationsController(IApplicationService applicationService)
{
this.applicationService = applicationService;
}
[HttpGet("{key}")]
public async Task<IActionResult> Get(string key)
{
var redirect = await applicationService.FindAsync(key);
if (redirect == null)
{
return NotFound();
}
else
{
return Ok(new ApplicationRedirectModel(redirect));
}
}
}
[Route("api/applications")]
public class ApplicationsController : Controller
{
[HttpGet("{key}")]
public async Task<IActionResult> Get([FromServices]IApplicationService applicationService, string key)
{
var redirect = await applicationService.FindAsync(key);
if (redirect == null)
{
return NotFound();
}
else
{
return Ok(new ApplicationRedirectModel(redirect));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment