Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building a MVC eCommerce Site in Under 5 Minutes

19,662 views

Published on

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.

Published in: Internet, Technology
  • Be the first to comment

Building a MVC eCommerce Site in Under 5 Minutes

  1. 1. Build a MVC eCommerce Site in Under 5 Minutes Gaines Kergosien @gainesk http://dotnetdude.net Sr. Solutions Architect http://www.vanick.com
  2. 2. 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
  3. 3. 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
  4. 4. MVC 4 4 View ModelController
  5. 5. MVC 5 5 View ModelController
  6. 6. Models  Class that represents data public class MyViewModel { public string Foo { get; set; } }
  7. 7. Models
  8. 8. Validators
  9. 9. MVC 9 9 View ModelController
  10. 10. 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
  11. 11. Views
  12. 12. 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
  13. 13. MVC 13 13 View ModelController
  14. 14. Controllers  Class derives from System.Web.Mvc.Controller  Generates the response to the browser request public class HomeController : Controller { public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; return View(); } public ActionResult About() { return View(); } }
  15. 15. Controller Actions  Public method of the Controller class  Cannot be overloaded or a static method public class HomeController : Controller { public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; return View(); } public ActionResult About() { return View(); } }
  16. 16. Controllers
  17. 17. Controller Actions
  18. 18. Controllers
  19. 19. Controller Actions  Get  Post
  20. 20. Questions? 20 20 View ModelController
  21. 21. View ModelBrowser Controller MVC 21 21
  22. 22. Routing http://www.mysite.com/Home/About/6 {controller} = Home {action} = About {id} = 6  Locations for nopCommerce  Nop.Web.Infrastructure.RouteProvider  Nop.Web.Infrastructure.GenericUrlRouteProvider
  23. 23. Route Provider
  24. 24. Generic URL Route Provider
  25. 25. nopCommerce Libraries  Nop.Core – Domain Objects & Infrastructure  Nop.Data – Data Access  Uses Entity Framework  Maps Tables to Domain Objects  Nop.Services – Business Logic
  26. 26. Domain Objects
  27. 27. Domain Objects
  28. 28. Domain Object Mapping
  29. 29. Services
  30. 30. Dependency Injection
  31. 31. Generic Repositories
  32. 32. LINQ Queries
  33. 33. nopCommerce Plugins  Loaded at runtime  Independent of core source  Consume events  Marketable  See next session!
  34. 34. nopCommerce Admin Site  Nop.Admin project under relative path /Admin  Uses AutoMapper to link Objects and Models
  35. 35. Contact Info Blog: http://dotnetdude.net Email: gaines [at] kergosien.net Twitter: @gainesk Rate this talk @ http://spkr8.com/t/35551

×