Вы находитесь на странице: 1из 14

2 years ago 23 Comments

A lightweight shopping cart


web application in ASP.NET
MVC 5. (/a-lightweightshopping-cart-webapplication-in-asp-net-mvc-5/)
Recently I decided to build a lightweight shopping cart web app in
ASP.NET MVC 5 so that it can be used by local businesses to take orders
online.
The app takes orders online and sends out an email to the shops owner.
The email contains all of the order information and the business owner
can charge it using their in store credit card management system.

It is very light weight, responsive, secure, and open source and it is built
on top of some really great technologies, all of which are open source as
well.
The source code can be found on GitHub here
(https://github.com/lbacaj/OpenOrderFramework).

The problem.
I have a lot of family and friends in the restaurant industry and others
that own small businesses and they are all facing the same type of
dilemma:
How to take advantage of the internet and the explosive growth of mobile
apps to expand their business.
They want to allow their customers to place an order online. They want
to charge it themselves and ship or deliver the items themselves. They
dont want any fancy system, a CMS, or anything with too much
complexity and to be frank they cant afford to maintain any of that.

They want simplicity. Once the app is deployed and running they can
maintain it with ease. I set out to build an extremely lightweight
framework that I could reuse across all of these different small
businesses and then I decided to give it away and open source it.

Most of these small businesses have static websites that show exactly
what they are selling but have no way of actually selling anything online
without adding complexity or cost.
Dont get me wrong apps like seamless and grub hub are great. They
allow restaurants to sell online and have wide reach but they also charge
restaurants anywhere between 10% to 20% of the order price. Not to
mention other types of shops dont even have services like these
available to them.
By providing a fully finished secure web app, that just requires some
configuration and deployment to your favorite hosting site, this
framework aims to give the power back to the local shop owners.

Why build another shopping cart?


While there are many great shopping carts out there, done in any
programming language used to build web applications, very few of them
solve this problem in a simple easy to maintain secure manner.

Most of these existing carts are bloated with lots of features which can
really mean lots of complexity. Take for example nopCommerce
(http://www.nopcommerce.com/), it took me longer to setup items and
configure a shop in there then it took me to write my own framework
that I could reuse.
Dont get me wrong features are nice but for the local shops and small
business owner I think just a clean way to take orders on their website is
more than enough.

Now for my favorite part.


The app uses a lot of exciting technologies that make development
extremely easy and fast. (I build this on the side after work and in less
than two weeks from start to its current state.)

The Technology Stack.


ASP.NET MVC 5 and .NET 4.5 at its core written in C#. I took advantage
of some of the asynchronous programming features of .NET 4.5, I
would like to stress some because I have more work to do on this one.
The app is extremely fast and very responsive and in all honesty was a
dream to write because these technologies are so nice to work with.
HTML 5 Front end development is extremely easy with a framework
like bootstrap. I simply took a free open source theme from
http://bootswatch.com (http://bootswatch.com) and had a beautiful
responsive UI that works great on mobile and desktop within a few
minutes.
Entity Framework 6 code first migration for all of the database work.
This makes it extremely fast and easy to deploy and working with
Entity 6 is so much fun. Allows for easy asynchronous write backs and
saves to the database without having to worry about writing any SQL.

(On a side note I once told a colleague of mine back at SunGard that I
hated writing SQL because it was so 1960-ish, I didnt mean that I dont
really thik SQL is that bad.)
SQL Server Express database, although entity makes it easy to use any
database behind this.
Identity 2.0 for the security aspects, Microsoft has some really great
template to get you up and running with a super secure site within an
hour. This allows for a great authentication and authorization system
that supports external logins from Google and Facebook and easily
allows for roles.
Mailgun for the emailing system and they have a great free 1000 email
program that these small businesses will generally never go over.
Windows Azure for hosting but in reality any ASP.NET hosting
provider will do.
D3.js for some analytics and charting so shop owners can track how
their online business is doing. I should note that this isnt fully
implemented as I was simply learning D3 while doing this. More will
be done on this one in the future for sure as D3 is one of the best UI
technologies I have come across.
There are also lots of other technologies such as
Visual Studio
TFS Online
Github
jQuery

Oh and I would really like to shout out AppVeyor


(http://www.appveyor.com/) they are extremely easy to use all in one
continuous integration system that automatically builds and tests your
app right off of github. It is truly a joy to work with and dont just take
my word for it go see what one of my favoret developers has to say
about it, Hanselman's Blog

(http://www.hanselman.com/blog/AppVeyorAGoodContinuousIntegrationSys

Finally the app is loosely based off the ASP.NET MVC 3 Music Store from
Microsoft, MVC Music Store (http://www.asp.net/mvc/tutorials/mvcmusic-store), but unlike that app this is much more full featured and

suitable for the real world. That app is a great way to learn how to build a
shopping cart though and my thanks goes to the developer, Jon
Galloway.

Email Address

First Name

Subscribe

W R IT T E N B Y

Louie Bacaj ()
Louie Bacaj is a Senior Software Engineer

S PR E A D T H E W O R D

with an M.S. in computer science;

()

experienced scaling multi-million dollar


software projects to several tier 1 financial
institutions.
New York City

Published on
June 20, 2014

23Comments

Coding.fitness

Recommend

Share

Jointhediscussion
AntonBacaj 2yearsago

Looksgreat
2

Reply Share

microwang 9monthsago

HI,

Login

SortbyBest

HI,
WhereshouldIgotodownloadthisniceshoppingcart?
Thanks.
Danial
2

Reply Share

JohanCastroAlfaro 2yearsago

Hi,isthereanytutorialorsomethinglikethatIcanfollowtoeditthisappandcustomizeitthe
wayIwant.IdonothaveexperienceinthisareaandIhavetodoanuniversityproject.Thanks.
1

Reply Share

RohanThakur 20daysago

Hi,Nicearticle,butitemsaccordingtoquantityismissinginthisshoppingcart.Thankssir
publishingforthiswebsitewhichhelpsusalot.

Reply Share

Sadie 2monthsago

WhenIrunUpdateDatabasefromthepackagemanagerinVS2015U2,Iamgettinganerror:
"NoDbContextwasfound.Ensurethatyou'reusingthecorrectassemblyandthatthetypeis
neitherabstractnorgeneric."AnythoughtsonwhatIneedtodototofixthisorwhattutorialI
shoulddigintotofigureitout?

Reply Share

Sadie>Sadie amonthago

Thereweretwoissues:IonlyhadSQLServerinstalled,notSQLServerExpress.OnceI
gottheSQLServerExpress2014installedIgotanerror"toupgradetheprojectdatabase
touselatestSQLServerExpressLocalDB".Thisissuewassolvedbygoinginand
changingtheconnectionstringtoconnecttoSQLServerExpress2014ratherthenSQL
ServerExpress2012.Itisnowupandrunning!

Reply Share

RadHa 2monthsago

Whenitrytoopenanyforminyourapplication,e.g.RegisterorLogin,Igetanexception
relatedtothecryptographicoperationforAntiforgerytoken.Theerroris"thespecifiedkeyisnot
avalidsizeforthisalgorithmAntiforgeryMVC".Anyideasonhowtosolvethis?
ExceptionDetails:System.Security.Cryptography.CryptographicException:Erroroccurred
duringacryptographicoperation.
SourceError:
Line8:@using(Html.BeginForm("Register","Account",FormMethod.Post,new{@class=
"formhorizontal",role="form"}))
Line9:{
Line10:@Html.AntiForgeryToken()
Line11:<h4>Createanewaccount.</h4>
Line12:<hr/>

Line12:<hr/>

Reply Share

NinaClarke 2monthsago

Thanksforthis,I'vebeenaskedtoputtogetherasimpleshopsitesothishassavedmeafairbit
oflegwork.I'vegotitusinganuptodateSQLExpressDBandamjustupdatingsomeofthe
templatestousebootstrapsrow/columnsfeaturesandgiveitamoretraditionalshoplook,but
otherwiseisexactlywhatIneed.

Reply Share

DevSaini 4monthsago

Firstofall,Iwanttothanksforsharingthisgoodarticleforshoppingcart.Ihaduseditinmy
project&allareworkingfine.Buttheirisoneissuewhileloadingtheproject.Ittakesavery
longtimetoloadtheproject.IthinkitmaybeduetosomethingusedTeamFoundationServer
VersionControlmessage.
Thesolutionyouareopeningisboundtosourcecontrolonthefollowingteamfoundation
server.................
Haveanyideatospeedupthisproject?

Reply Share

Nikhil>DevSaini 3monthsago

Deletethe.suofilethatgetscreated.

Reply Share

DhouhaBabay 6monthsago

Arethereanytutorialforimplementation?

Reply Share

Alok 7monthsago

Errorcomewheniopentheproject
TF30063:Y ouarenotauthorizedtoaccesshttps://louiebacaj.visualstudi....
Theactivesolutionhasbeentemporarilydisconnectedfromsourcecontrolbecausetheserveris
unavailable.Toattempttoreconnecttosourcecontrol,closeandthenreopenthesolutionwhen
theserverisavailable.Ifyouwanttoconnectthissolutiontoanotherserver,usetheChange
SourceControldialog.
Themappingsforthesolutioncouldnotbefound.
Theactivesolutionhasbeentemporarilydisconnectedfromsourcecontrolbecausetheserveris
unavailable.Toattempttoreconnecttosourcecontrol,closeandthenreopenthesolutionwhen
theserverisavailable.Ifyouwanttoconnectthissolutiontoanotherserver,usetheChange
SourceControldialog.
Themappingsforthesolutioncouldnotbefound.

Reply Share

AnandKhobragade 7monthsago

verynicejob!!

Reply Share

TraiThngT 9monthsago

Idon'tseetheupdate,anddeletefunctionscart.
Iwanttoeditquantitytextbox,theniclickupdatecartbutton.MyCartwillbeupdate
However,Ihopetheniclickdeletecartbutton.Mycartwillbedelete
Ireallyappreciateyourhelp.

Reply Share

ColinLim ayearago

Thanksforsharingandislookingforwardforthetutorial.

Reply Share

Bill ayearago

Juststumbledacrossthislittlegem.I'vebeenmullingshoppingcartsforsomeweeksnowand
Ifoundthefollowing:
1)Somuchbloatit'snotevenfunny
2)NoteasilyintegratedwithexistingMVC5sites
3)Costly
4)Maintenancenightmare
IhaveprogrammedcartsinotherlanguagesandwaslookingformyfirstIthinktakingsome
ideasfromyourcodeIcanhavemycartdone,myway,theweekend.Thanksforsharingand
forsharingthecode.

Reply Share

HanSiongJie ayearago

Thankyousir!Thiswebappreallyhelpsalotformycollegefinalyearproject.Lookingforward
onyourupcomingguide.

Reply Share

Fredy ayearago

Thankyouforsharing!

Reply Share

LuljanBacaj

Mod >Fredy ayearago

Y ou'rewelcome.
Iplanonmakingsomechangessoonsolookoutforthat.Ihavebeenworkingona
guideongettingstartedwithitaswellbecauseitwasputtogetherprettyquickly.
1

Reply Share

Fredy>LuljanBacaj ayearago

Great!Atutorialontheway?GoodluckandThankyouagain!

Reply Share

Mahi 2yearsago

Howtodownload?

Reply Share

Fredy>Mahi ayearago

herehttps://github.com/lbacaj/Open...

Reply Share

GregMacbean 2yearsago

JustdownloadedIamlookingforwardtocheckingitout.

Reply Share

ALSOONCODING.FITNESS

Lets"MarryUp"Angularto.NET
5comments2yearsago

SoftwareEngineersshouldalllearn
JavaScript.

AvatarEnkelejdCeka Greatargumentanddeserves
someseriousconsideration.Alsothankyoufor
notjustthrowingthearticletogetherintoa

67comments2yearsago

ASP.NETMVCandGoogleStreetView/
StaticMapsAPI's.

PerseveranceandBurningout

1comment2yearsago

AvatarOldPotatoesGoodpoint,wellmade.

AvatarAntonyClementsIamgoingtorefuteyour
wholeargumenthere.JavaScriptisalanguage
forbrowsersandwebapplications.Ifyouare

1comment2yearsago

AvatarOldPotatoesNice!

Subscribe

AddDisqustoyoursiteAddDisqusAdd

Privacy

2016. All Rights Reserved.


Ghostium Theme (http://ghostium.oswaldoacauan.com/) by @oswaldoacauan (http://twitter.com/oswaldoacauan)
Proudly published with Ghost (http://ghost.org)

Вам также может понравиться