forked from devxzero/blogpost_files
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ASP.NET MVC 3 implementation.
- Loading branch information
Showing
30 changed files
with
13,881 additions
and
0 deletions.
There are no files selected for viewing
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
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; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace mvcapp.Controllers | ||
{ | ||
using System.Collections.Generic; | ||
using System.Web.Mvc; | ||
|
||
using Models; | ||
|
||
public class ProductsController : Controller | ||
{ | ||
#region Public Methods | ||
|
||
public ActionResult Index(int n) | ||
{ | ||
List<Product> products = Service.GetProducts(n); | ||
return View(products); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ Application Codebehind="Global.asax.cs" Inherits="mvcapp.MvcApplication" Language="C#" %> |
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
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); | ||
} | ||
} | ||
} |
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
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 | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace mvcapp.Models | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
public class Product | ||
{ | ||
#region Constructors and Destructors | ||
|
||
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 | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
namespace mvcapp.Models | ||
{ | ||
using System.Collections.Generic; | ||
|
||
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 List<Product> GetProducts(int max) | ||
{ | ||
return products.GetRange(0, max); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
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
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")] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@{ | ||
ViewBag.Title = "Index"; | ||
ViewBag.PageName = "Products listing"; | ||
} | ||
@model IEnumerable<mvcapp.Models.Product> | ||
<table> | ||
<!-- The products --> | ||
@foreach(var product in Model){ | ||
<tr> | ||
<td> | ||
@{Html.RenderPartial("_Product", product);} | ||
</td> | ||
<td> | ||
@string.Join(",", product.Categories.Select(c=> c.Name)) | ||
</td> | ||
</tr> | ||
} | ||
</table> |
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
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> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!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> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@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> |
Oops, something went wrong.