27 lines
516 B
C#
27 lines
516 B
C#
using System.Linq;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using pwt_0x01_ng.Models;
|
|
using pwt_0x01_ng.Models.Database;
|
|
|
|
namespace pwt_0x01_ng.Controllers
|
|
{
|
|
public class ProductsController : Controller
|
|
{
|
|
readonly DBContext dbctx;
|
|
|
|
public ProductsController(DBContext dbctx){
|
|
this.dbctx = dbctx;
|
|
}
|
|
public IActionResult Detail(int id){
|
|
Product p = dbctx.Product.Where(p_item => p_item.id == id).FirstOrDefault();
|
|
if (p != null)
|
|
{
|
|
return View(p);
|
|
}
|
|
else
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
}
|
|
} |