Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Mvc;
  6. using EcommerceApp2.Models;
  7.  
  8. namespace EcommerceApp2.Controllers
  9. {
  10.     public class ProductsController : Controller
  11.     {
  12.         private readonly ProductService _service;
  13.  
  14.         public ProductsController(ProductService service)
  15.         {
  16.             _service = service;
  17.         }
  18.  
  19.         public IActionResult Index()
  20.         {
  21.             return View(_service.GetProducts());
  22.         }
  23.  
  24.         public IActionResult Product()
  25.         {
  26.             // return View(new ProductsModel() { Id=42, Name="Phone", Price=450, Category="High-Tech" });
  27.             return View(_service.GetProductById(1));
  28.         }
  29.  
  30.         public IActionResult Error()
  31.         {
  32.             return View();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement