1
0
mirror of https://github.com/rudollee/LearningMVC.git synced 2025-06-07 07:56:14 +00:00
LearningMVC/Razor/Controllers/HomeController.cs
2017-04-03 23:33:58 +09:00

53 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Razor.Models;
namespace Razor.Controllers
{
public class HomeController : Controller
{
Product myProduct = new Product
{
ProductID = 1,
Name = "Kayak",
Description = "A boat for one person",
Category = "Watersports",
Price = 275M
};
public ActionResult Index()
{
return View(myProduct);
}
public ActionResult NameAndPrice()
{
return View(myProduct);
}
public ActionResult DemoExpression()
{
ViewBag.ProductCount = 1;
ViewBag.ExpressShip = true;
ViewBag.ApplyDiscount = false;
ViewBag.Supplier = null;
return View(myProduct);
}
public ActionResult DemoArray()
{
Product[] array =
{
new Product {Name = "Kayak", Category = "Watersports", Price = 275M },
new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
new Product {Name = "Soccer ball", Category = "Soccer", Price = 19.50M },
new Product {Name = "Coner flag", Category = "Soccer", Price = 34.95M }
};
return View(array);
}
}
}