+ All Categories
Home > Internet > Building a MVC eCommerce Site in Under 5 Minutes

Building a MVC eCommerce Site in Under 5 Minutes

Date post: 15-Jan-2015
Category:
Upload: gaines-kergosien
View: 2,272 times
Download: 1 times
Share this document with a friend
Description:
For those of us who have spent most of our careers building business applications, the prospect of creating an e-commerce storefront can be quite daunting. Not only do you have to deal with calculating tax, estimating shipping and accepting payments, but employees need a way to manage products, discounts and marketing content. Thankfully, there's an open source e-commerce solution written in Microsoft ASP.NET MVC named nopCommerce that provides all this functionality and much more. I was so impressed by both the functionality and the underlying architecture that I've created a presentation which I believe will serve as a great introduction to MVC as well as a tutorial on developing custom storefronts using nopCommerce. We start off with a brief overview of basic MVC concepts accompanied by examples within the nopCommerce code. This includes strongly typed Razor views, HTML helpers, jQuery ajax calls, and fluent validation. Once everyone understands how the website works, we dive into the infrastructure by introducing WCF services, using a generic repository with Entity Framework(EF4) and LINQ, as well as Dependency Injection (DI) with Automapper.
Popular Tags:
35
Build a MVC eCommerce Site in Under 5 Minutes Gaines Kergosien @gainesk http://dotnetdude.net Sr. Solutions Architect http://www.vanick.com
Transcript
Page 1: Building a MVC eCommerce Site in Under 5 Minutes

Build a MVC eCommerce Sitein Under 5 Minutes

Gaines Kergosien@gainesk

http://dotnetdude.net

Sr. Solutions Architecthttp://www.vanick.com

Page 2: Building a MVC eCommerce Site in Under 5 Minutes

2

What is nopCommerce? Open Source

Product Catalog Categories Products/Variants

Customer Management

Order Management Mobile Support Discounts Wish Lists Gift Cards Newsletters

Recurring Payments

Reporting Payment Methods Shipping Methods Taxes External Auth Polls News Blogs Forums Multiple Stores

Page 3: Building a MVC eCommerce Site in Under 5 Minutes

Why this topic?

3

Why MVC and WCF? Decoupled Scalable Reusable Maintainable

Why nopCommerce? Top eCommerce app on MS Web

Matrix Open Source (GPLv2 License)

3

Page 4: Building a MVC eCommerce Site in Under 5 Minutes

MVC

44

View

ModelController

Page 5: Building a MVC eCommerce Site in Under 5 Minutes

MVC

55

View

ModelController

Page 6: Building a MVC eCommerce Site in Under 5 Minutes

Models

Class that represents data

public class MyViewModel{ public string Foo { get; set; }}

Page 7: Building a MVC eCommerce Site in Under 5 Minutes

Models

Page 8: Building a MVC eCommerce Site in Under 5 Minutes

Validators

Page 9: Building a MVC eCommerce Site in Under 5 Minutes

MVC

99

View

ModelController

Page 10: Building a MVC eCommerce Site in Under 5 Minutes

Views

A view is a standard (X)HTML document that can contain scripts.

Views support ASP.NET markup or Razor Razor markup used in nopCommerce

nopCommerce views are strongly typed

Page 11: Building a MVC eCommerce Site in Under 5 Minutes

Views

Page 12: Building a MVC eCommerce Site in Under 5 Minutes

HTML Helpers

Methods which typically return string. Used to generate standard HTML

elements textboxes, dropdown lists, links etc.

Usage is optional You can create your own HTML Helpers

Page 13: Building a MVC eCommerce Site in Under 5 Minutes

MVC

1313

View

ModelController

Page 14: Building a MVC eCommerce Site in Under 5 Minutes

Controllers

Class derives from System.Web.Mvc.Controller

Generates the response to the browser requestpublic class HomeController : Controller{ public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!";

return View(); }

public ActionResult About() { return View(); }}

Page 15: Building a MVC eCommerce Site in Under 5 Minutes

Controller Actions

Public method of the Controller class

Cannot be overloaded or a static methodpublic class HomeController : Controller

{ public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!";

return View(); }

public ActionResult About() { return View(); }}

Page 16: Building a MVC eCommerce Site in Under 5 Minutes

Controllers

Page 17: Building a MVC eCommerce Site in Under 5 Minutes

Controller Actions

Page 18: Building a MVC eCommerce Site in Under 5 Minutes

Controllers

Page 19: Building a MVC eCommerce Site in Under 5 Minutes

Controller Actions

Get

Post

Page 20: Building a MVC eCommerce Site in Under 5 Minutes

Questions?

2020

View

ModelController

Page 21: Building a MVC eCommerce Site in Under 5 Minutes

View

ModelBrowser Controller

MVC

2121

Page 22: Building a MVC eCommerce Site in Under 5 Minutes

Routing

http://www.mysite.com/Home/About/6 {controller} = Home {action} = About {id} = 6

Locations for nopCommerce Nop.Web.Infrastructure.RouteProvider Nop.Web.Infrastructure.GenericUrlRoutePr

ovider

Page 23: Building a MVC eCommerce Site in Under 5 Minutes

Route Provider

Page 24: Building a MVC eCommerce Site in Under 5 Minutes

Generic URL Route Provider

Page 25: Building a MVC eCommerce Site in Under 5 Minutes

nopCommerce Libraries Nop.Core – Domain Objects &

Infrastructure Nop.Data – Data Access

Uses Entity Framework Maps Tables to Domain Objects

Nop.Services – Business Logic

Page 26: Building a MVC eCommerce Site in Under 5 Minutes

Domain Objects

Page 27: Building a MVC eCommerce Site in Under 5 Minutes

Domain Objects

Page 28: Building a MVC eCommerce Site in Under 5 Minutes

Domain Object Mapping

Page 29: Building a MVC eCommerce Site in Under 5 Minutes

Services

Page 30: Building a MVC eCommerce Site in Under 5 Minutes

Dependency Injection

Page 31: Building a MVC eCommerce Site in Under 5 Minutes

Generic Repositories

Page 32: Building a MVC eCommerce Site in Under 5 Minutes

LINQ Queries

Page 33: Building a MVC eCommerce Site in Under 5 Minutes

nopCommerce Plugins Loaded at runtime

Independent of core source Consume events Marketable See next session!

Page 34: Building a MVC eCommerce Site in Under 5 Minutes

nopCommerce Admin Site Nop.Admin project under relative

path /Admin Uses AutoMapper to link Objects

and Models

Page 35: Building a MVC eCommerce Site in Under 5 Minutes

Contact Info

Blog: http://dotnetdude.net

Email: gaines [at] kergosien.net

Twitter: @gainesk

Rate this talk @ http://spkr8.com/t/35551


Recommended