Last active
May 18, 2019 19:39
-
-
Save seangwright/6ca5f6980c5e75b9b59e37d2c83063c2 to your computer and use it in GitHub Desktop.
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
public class ProductsController : Controller | |
{ | |
private readonly IProductsQuery productsQuery; | |
private readonly IProductDetailQuery productDetailQuery; | |
public ProductsController( | |
IProductsQuery productsQuery, | |
IProductDetailQuery productDetailQuery) | |
{ | |
// ... | |
} | |
[HttpGet] | |
public ActionResult Index() => | |
View(new ProductIndexViewModel(productsQuery.Execute())); | |
[HttpGet] | |
public ActionResult Detail(int productId) | |
{ | |
var product = productDetailQuery.Execute(productId); | |
return product is null | |
? new HttpNotFoundResult($"Product with Id {productId}") | |
: View(new ProductDetailViewModel(product)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment