Using mvcquick. Framework to reconstruct MVC music store (1)

Source: Internet
Author: User
Tags visual studio 2010
Musicstore

MVC music store is based on the best ASP. netmvc getting started tutorial that guides you how to use MVC and Visual Studio for web development. The latest version of MVC music store is developed based on ASP. net mvc 3 using Visual Studio 2010.

Mvcquick. Framework

Mvcquick. An original open-source framework for rapid development of ASP. net mvc applications. Mvcquick. framework includes a repository, an IOC container, a log manager, and a security provider.

Object definition:

    public class Album : EntityBase
{
public string Title { get; set; }
public decimal Price { get; set; }
public string AlbumArtUrl { get; set; }
public Genre Genre { get; set; }
public Artist Artist { get; set; }
public IEnumerable<OrderDetail> OrderDetails { get; set; }
}

 

Storage:

// Global configuration
Nhibernatemanager. configuration ();
Nhibernatemanager. addmapping ("mvcquick ",
Typeof (entitybase). assembly,
Typeof (album). Assembly );
Nhibernatemanager. updateschema ();
Classiccontainer. register <nhibernaterepository> ("nhibernaterepository ");


// Use
Repository. Save <cart> (cartitem );
VaR cartitems =
Repository. query <cart> ()
. Where (x => X. guid = shoppingcartid)
. Tolist ();

 

IOC container:

ClassicContainer.Register<AccountController>("Account", properties);

Logs:

// Global configuration
Logger. configurelog4net (httpcontext. Current. server. mappath ("~ /Log "), loglevel. info, loglevel. info );

// Use
Logger logger = logger. getlogger (filtercontext. Controller. GetType ());
Logger. Error (filtercontext. Exception );

 

Member provider:

    <membership  defaultProvider="ClassicMembershipProvider">
<providers>
<clear/>
<add name="ClassicMembershipProvider" type="MVCQuick.Framework.Security.ClassicMembershipProvider"
enablePasswordRetrieval="false" enablePasswordReset="false" requiresUniqueEmail="false"
requiresQuestionAndAnswer="false" minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0" applicationName="MVCQuick" passwordFormat="Hashed" />
</providers>
</membership>

 

Reconstruction

1. Model

Modify the object class to inherit from mvcquick. Framework. entitybase

Use mvcquick. Framework. repository to replace Entity Framework

2. Controller

Use mvcquick. Framework. container to decouple the controller from the Data Access Object

3. View

Unchanged, modify some fields

4. Configuration

Replace the default member provider and role provider with mvcquick. Framework. Security. classicmembershipprovider and mvcquick. Framework. Security. classicroleprovider.

Added the log function.

5. Test

Test Running Effect

 

Source code download: http://mvcquick.codeplex.com/

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.