14
2 years ago · 23 Comments A lightweight shopping cart web app lication in ASP.NET MVC 5 . (/a-lightweight- shopping-cart-web- application-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.

A Lightweight Shopping Cart Web Application in ASP

Embed Size (px)

Citation preview

Page 1: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 1/14

2 years ago · 23 Comments

A lightweight shopping cartweb application in ASP.NETMVC 5. (/a-lightweight-shopping-cart-web-application-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 ordersonline.

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.

Page 2: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 2/14

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

.

Page 3: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 3/14

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

don’t want any fancy system, a CMS, or anything with too much

complexity and to be frank they can’t afford to maintain any of that.

Page 4: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 4/14

They want simplicity. Once the app is deployed and running they canmaintain 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.

Page 5: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 5/14

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.

Don’t 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 don’t 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.

Page 6: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 6/14

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.

Don’t 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.)

Page 7: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 7/14

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.

Page 8: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 8/14

(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 didn’t 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 isn’t 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

Page 9: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 9/14

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 don’t 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/AppVeyorAGoodContinuousIntegratio

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/mvc-

music-store), but unlike that app this is much more full featured and

Page 10: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 10/14

23 Comments 1

• •

Anton Bacaj  •  

Looks great

microwang  •  

()

R ITTEN BY

Louie Bacaj ()

ouie Bacaj is a Senior Software Engineer 

with an M.S. in computer science;

experienced scaling multi-million dollar 

software projects to several tier 1 financial

institutions.

ew York City

Published onune 20, 2014

S PR EAD TH E WOR D

   

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

Page 11: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 11/14

• •

HI,

 Where should I go to download this nice shopping cart?

Thanks.

Danial

• •

Johan Castro Alfaro  •  

Hi, is there any tutorial or something like that I can follow to edit this app and customize it the

 way I want. I do not have experience in this area and I have to do an university project. Thanks.

• •

Rohan Thakur   •  

Hi, Nice article, but items according to quantity is missing in this shopping cart. Thanks sir

publishing for this website which helps us alot.

• •

Sadie  •  

 When I run Update-Database from the package manager in VS 2015 U2, I am getting an error:

"No DbContext was found. Ensure that you're using the correct assembly and that the type isneither abstract nor generic." Any thoughts on what I need to do to to fix this or what tutorial I

should dig into to figure it out?

• •

Sadie  •  

There were two issues: I only had SQL Server installed, not SQL Server Express. Once I

got the SQL Server Express 2014 installed I got an error "to upgrade the project database

to use latest SQL Server Express LocalDB". This issue was solved by going in and

changing the connection string to connect to SQL Server Express 2014 rather then SQL

Server Express 2012. It is now up and running!

Rad Ha  • 

 When i try to open any form in y our application, e.g. Register or Login, I get an exception

related to the cryptographic operation for Antiforgerytoken. The error is "the specified key is not

a valid size for this algorithm Antiforgery MVC". Any ideas on how to solve this?

Exception Details: System.Security.Cryptography.CryptographicException: Error occurred

during a cryptographic operation.

Source Error:

Line 8: @using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class =

"form-horizontal", role = "form" }))

Line 9: {

Line 10: @Html.AntiForgeryToken()

Line 11: <h4>Create a new account.</h4>

 

Page 12: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 12/14

• •

ne 12: < r >

• •

Nina Clarke  •  

Thanks for this, I've been asked to put together a simple shop site so this has saved me a fair bit

of leg work. I've got it using an up to date SQL Express DB and am just updating some of the

templates to use bootstraps row/columns features and give it a more traditional shop look, but

otherwise is exactly what I need.

• •

Dev Saini  •  

First of all, I want to thanks for sharing this good article for shopping cart. I had used it in my 

project & all are working fine. But their is one issue while loading the project. It takes a very 

long time to load the project. I think it may be due to some thing used Team Foundation Server

 Version Control message.

The solution you are opening is bound to source control on the following team foundation

server.................

Have any idea to speed up this project?

• •

Nikhil  •  

Delete the .suo file that gets created.

• •

Dhouha Babay  •  

 Are there any tutorial for implementation ?

• •

Alok  •  

Error come when i open the project

TF30063: You are not authorized to access https://louiebacaj.visualstudi....

The active solution has been temporarily disconnected from source control because the server is

unavailable. To attempt to reconnect to source control, close and then re-open the solution when

the server is available. If you want to connect this solution to another server, use the Change

Source Control dialog.

The mappings for the solution could not be found.

The active solution has been temporarily disconnected from source control because the server isunavailable. To attempt to reconnect to source control, close and then re-open the solution when

the server is available. If you want to connect this solution to another server, use the Change

Source Control dialog.

The mappings for the solution could not be found.

• •

Anand Khobragade  •  

 very nice job!!

Page 13: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 13/14

• •

Trai Tháng Tư  •  

I don't see the update, and delete functions cart .

- I want to edit quantity textbox, then i click update cart button. My Cart will be update

- However, I hope then i click delete cart button. My cart will be delete

I really appreciate your help.

• •

Colin Lim  •  

Thanks for sharing and is looking forward for the tutorial.

• •

Bill  •  

Just stumbled across this little gem. I've been mulling shopping carts for some weeks now - and

I found the following:

1) So much bloat it's not even funny 

2) Not easily integrated with existing MVC 5 sites

3) Costly 

4) Maintenance nightmare

I have programmed carts in other languages and was looking for my first - I think taking some

ideas from your code I can have my cart done, my way, the weekend. Thanks for sharing and

for sharing the code.

• •

Han Siong Jie  •  

Thank you sir! This web app really helps a lot for my college final year project. Looking forward

on your upcoming guide.

• •

Fredy  •  

Thank you for sharing!

• •

Luljan Bacaj  • Mod

ou're welcome.

I plan on making some changes soon so look out for that. I have been working on a

guide on getting started with it as well because it was put together pretty quickly.

• •

Fredy  • 

Great! A tutorial on the way? Good luck and Thank you again!

• •

Mahi  •  

How to download?

Page 14: A Lightweight Shopping Cart Web Application in ASP

7/25/2019 A Lightweight Shopping Cart Web Application in ASP

http://slidepdf.com/reader/full/a-lightweight-shopping-cart-web-application-in-asp 14/14

Lets "Marry Up" Angular to .NET

• •

 Avat   — Great argument and deserves

some serious consideration. Also thank y ou for

not just throwing the article together into a …

Software Engineers should all learn

JavaScript.

• •

 Avat   — I am going to refute your

 whole argument here. Jav aScript is a language

for browsers and web applications. If you are …

ASP.NET MVC and Google Street View /

Static Maps API's.• •

 Avat   — Nice!

Perseverance and Burning out

• •

 Avat   — Good point, well made.

CODING.FITNESS

• •

Fredy  •  

here https://github.com/lbacaj/Open...

• •

Greg Macbean  •  

Just downloaded I am looking forward to checking it out.

© 2016. All Rights Reserved.

Ghostium Theme (http://ghostium.oswaldoacauan.com/) by @oswaldoacauan (http://twitter.com/oswaldoacauan)

Proudly published with Ghost (http://ghost.org)