p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 (http://p2p.wrox.com/forumdisplay.php?f=252)
-   -   Webshop modification (http://p2p.wrox.com/showthread.php?t=49027)

El Presidente October 14th, 2006 10:27 AM

Webshop modification
 
Good day all.

Very good book and nice forum.
One question.
Is there some way how to get two or more webshops running within this example?
Lets say, there would be one more page showing all available webshops and they would have all available products and so on...
Or is it major change and should not be done?

Thanks for reading this.

Peter


Imar October 15th, 2006 08:56 AM

Hi Peter,

I am glad you like the book....

The whole idea about the applications in this book is reuse. You should be able to take the shop and reuse it in scenarios where you see fit. So, yes, this should definitely be possible.

But you need to think about how you want to approach this. Do the shops get their own database and products? Or do you want to share content between the sites. Does each shop get a unique look and feel or do you want to share presentation as well? And, also important, how would users browse to the shop? E.g. www.domain.com/Shop1 and www.domain.com/Shop2 or www.shop1.com and www.shop2.com?

If you can elaborate a bit about what you have in mind, I may be able to give better suggestions and advice.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.

El Presidente October 24th, 2006 05:45 AM

Hey Imar!

Thanks for reply to my problem.
I was shopping around in last couple of weeks(buying and reading other books with similar solutions) but im back here admiting that this is best material available.

So my problem is: I would like to create 3 different webshops. They would share one DB file (so membership same for all shops) and would be accessed as www.domain.com/shop1, www.domain.com/shop2....
They would sell different products.

If you can just hint few things, I would much appreciate.

Peter

Imar October 24th, 2006 02:11 PM

Hi Peter,

If you want to have different shops under the same domain, you need some way to determine the current "shop" in your code. One way to do this is to use a common base page that all your pages derive from. That's the way I designed a similar shop solution that was the basis for the (simplified) shop in the book.

In your App_Code folder, add a class called BasePage for example, that inherits from System.Web.UI.Page, like this:
Code:

Public Class BasePage
  Inherits System.Web.UI.Page
End Class

Then make your pages in the site inherit from that BaseClass instead of from System.Web.UI.Page (which is the default).

Next, give this BasePage class a read-only property like CurrentSite. This can be an Integer, or an enumeration for example that represents the current site. In the getter for this property, look at the current path, and based on something like /Site1/ or /Site2/ return the right shop number.

Next, in the same BaseClass, in the OnPreInit event you can (if that's a requirement) dynamically switch the MasterPage or the Theme to give each site a unique visual appearance.

Another thing you need to take into account is displaying the right products. However, with the CurrentSite property on the BasePage you can always see what site you're in and base your queries on that. That is, pass something like Me.CurrentSite to select methods that return your products.

You need to apply the same stuff to the Management section, so you can add products for the various shops.

Of course there's more stuff to take into account, but it's difficult to recommend anything without knowing what route you're going to take. I'll be more than happy to provide more help when you start with this and run into unforeseen issues....

Suggested reading for a BasePage and switching MasterPages:

ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps
Establish common ASP.NET page features through inheritance


Cheers,


Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Reptile by Nine Inch Nails (Track 12 from the album: The Downward Spiral) What's This?

saf November 16th, 2006 11:41 AM

Hi Imar -

I'm looking to do something similiar to what you describe here. For example, I will have users login by selecting their shopname, entering password and based on valid login direct them to their shop... Shops will share a database with shopid as key and share presentation.
I imagine when I get to rolling this out I will have one domain name accessed www.domain.com/shop1. So, similar to what Peter is trying to do. Any chance you have a sample of this in your bag of tricks that would get me going?

Thanks!


Imar November 18th, 2006 12:00 PM

Hi saf,

Can you explain with a bit more detail what kind of information you need? Doesn't my previous post get you in the right direction?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.

saf November 22nd, 2006 12:19 PM

Hi Imar -

Nevermind. I think I'm on the right track. Thanks for getting back to me though...


Imar November 25th, 2006 07:30 AM

You're welcome. Hope it's working out....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.

El Presidente November 27th, 2006 08:28 AM

Hey Imar!

This is not directly related to webshop, but im trying to get some reports printed.
As for example for current user, to display his daily/monthly spendings.
I can see, that there are tables that are recording transactions, but i was thinking about the way
how to determine current user (who is logged in) and im struggling with it.

Thanks for reading this.

Peter


Imar November 27th, 2006 04:53 PM

Hi Peter,

The column CustomerId in the table OrderBase is the user's ID from the aspnet_Users table. You can use this ID to find specific orders (and their details) for a user. You can get at the user's ID with the following code:
Code:

Dim myUser As MembershipUser = Membership.GetUser()
Dim userId As Guid = CType(myUser.ProviderUserKey, Guid)

You can then pass this ID into the DAL and forward it to a stored procedure that queries the orders for a user like this:
Code:

SELECT    Id, OrderDate, CustomerId, FirstName, LastName, Street, ZipCode, City, Country
FROM        OrderBase
WHERE    (CustomerId = @userId)

You can join the OrderBase table on the OrderDetail table to get related order info.

Don't forget that Membership.GetUser() only returns a valid user when the current user is logged in.

Does this put you in the right direction?

Is this shop live somewhere on the Internet? Would love to see how it is used....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.


All times are GMT -4. The time now is 10:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.