Skip to content
This repository was archived by the owner on May 28, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions aspnetmvc-3/Content/default.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
body{
margin:0;
padding:0;
line-height: 1.5em;
}

b{font-size: 110%;}
em{color: red;}

#maincontainer{
width: 840px; /*Width of main container*/
margin: 0 auto; /*Center container on page*/
}

#topsection{
background: #EAEAEA;
height: 90px; /*Height of top section*/
}

#topsection h1{
margin: 0;
padding-top: 15px;
}

#contentwrapper{
float: left;
width: 100%;
}

#contentcolumn{
margin-left: 200px; /*Set left margin to LeftColumnWidth*/
}

#leftcolumn{
float: left;
width: 200px; /*Width of left column*/
margin-left: -840px; /*Set left margin to -(MainContainerWidth)*/
background: #C8FC98;
}

#footer{
clear: left;
width: 100%;
background: black;
color: #FFF;
text-align: center;
padding: 4px 0;
}

#footer a{
color: #FFFF80;
}

.innertube{
margin: 10px; /*Margins for inner DIV inside each column (to provide padding)*/
margin-top: 0;
}
19 changes: 19 additions & 0 deletions aspnetmvc-3/Controllers/ProductsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace mvcapp.Controllers
{
using System.Web.Mvc;

using Models;

public class ProductsController : Controller
{
#region Public Methods

public ActionResult Index(int n)
{
var products = Service.GetProducts(n);
return View(products);
}

#endregion
}
}
1 change: 1 addition & 0 deletions aspnetmvc-3/Global.asax
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%@ Application Codebehind="Global.asax.cs" Inherits="mvcapp.MvcApplication" Language="C#" %>
40 changes: 40 additions & 0 deletions aspnetmvc-3/Global.asax.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace mvcapp
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801

public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}

public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

}

protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();

RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
}
20 changes: 20 additions & 0 deletions aspnetmvc-3/Models/Category.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace mvcapp.Models
{
public class Category
{
#region Constructors and Destructors

public Category(string name)
{
this.Name = name;
}

#endregion

#region Public Properties

public string Name { get; private set; }

#endregion
}
}
36 changes: 36 additions & 0 deletions aspnetmvc-3/Models/Product.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace mvcapp.Models
{
using System.Collections.Generic;
using System.Linq;

public class Product
{
#region Constructors and Destructors

public Product()
{
}

public Product(string name, int price, string description, params Category[] categories)
{
this.Name = name;
this.Price = price;
this.Description = description;
this.Categories = categories.ToList();
}

#endregion

#region Public Properties

public List<Category> Categories { get; set; }

public string Description { get; set; }

public string Name { get; set; }

public int Price { get; set; }

#endregion
}
}
49 changes: 49 additions & 0 deletions aspnetmvc-3/Models/Service.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace mvcapp.Models
{
using System.Collections.Generic;
using System.Linq;

public class Service
{
#region Constants and Fields

private static readonly List<Category> categories = new List<Category>();

private static readonly List<Product> products = new List<Product>();

#endregion

#region Constructors and Destructors

static Service()
{
for (var i = 0; i < 5; i++)
{
string name = (1000 + i).ToString();
categories.Add(new Category(name));
}

for (var i = 0; i < 20000; i++)
{
string name = i.ToString();
string description = (i * i).ToString();

var product = new Product(name, i, description);

product.Categories.AddRange(categories);
products.Add(product);
}
}

#endregion

#region Public Methods

public static IEnumerable<Product> GetProducts(int max)
{
return products.Take(max);
}

#endregion
}
}
35 changes: 35 additions & 0 deletions aspnetmvc-3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("mvcapp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("mvcapp")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("edd122e9-baef-4fc2-8edb-9e7c95158d8d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
14 changes: 14 additions & 0 deletions aspnetmvc-3/Views/Products/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@{
ViewBag.Title = "Product listing";
ViewBag.PageName = "Product listing";
}
@model IEnumerable<mvcapp.Models.Product>
<table>
<!-- The products -->
@foreach (var product in Model)
{
<tr><td>@Html.Partial("Product", product)</td>
<td>@string.Join(", ", product.Categories.Select(c=> c.Name))</td>
</tr>
}
</table>
5 changes: 5 additions & 0 deletions aspnetmvc-3/Views/Products/Product.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@model mvcapp.Models.Product
<div class="product">
<img src="@(Model.Name).jpg" />
<span class="productname">@Model.Name</span>, <span class="price">$@Model.Price</span>
</div>
15 changes: 15 additions & 0 deletions aspnetmvc-3/Views/Shared/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@{
Layout = null;
}

<!DOCTYPE html>
<html>
<head>
<title>Error</title>
</head>
<body>
<h2>
Sorry, an error occurred while processing your request.
</h2>
</body>
</html>
33 changes: 33 additions & 0 deletions aspnetmvc-3/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="@Url.Content("~/Content/default.css")" media="screen" rel="stylesheet" type="text/css" />
<!-- Title needs to be injected -->
<title>@ViewBag.Title</title>
</head>
<body>
<div id="maincontainer">
<div id="topsection">
<div class="innertube"><h1>Company Title .....</h1></div>
</div>
<div id="contentwrapper">
<div id="contentcolumn">
<!-- Page name needs to be injected -->
<div><h2>@ViewBag.PageName</h2></div>
<div class="innertube">
<!-- The content that is unique for each page -->
@RenderBody()
</div>
</div>
</div>
<div id="leftcolumn">
<div class="innertube">
<h3>Side bar.....</h3>
</div>
</div>
<div id="footer">footer.....</div>
</div>
</body>
</html>
Loading