Solved

Create a class for registrations or not? asp.net

Posted on 2012-03-21
4
341 Views
Last Modified: 2012-03-21
I'm still struggling with understanding OOP so this is a pretty basic question.

I'm not sure if building a custom class for this is necessary or possible. I have a friend that told me, "If you do something over and over, build a class." But I'm not sure in this case if the system.net.mail and database stuff is as good as it gets.

The company I work for does a lot of events. The way I handle it now is to build a registration page that has the form, inserts the registration to the database and then build a report page.

But I have to do this every time there's an event.

The form has name, title, address, etc. Just basic information. There is only one field that comes and goes, the rest of the fields are the same on every registration page. I use code behind to do the parameterized inserts.

So my question is, should I build a class or not? Or does this have to be done for each and every page the way I'm doing it now?

Thanks,
mh
0
Comment
Question by:MHenry
  • 2
  • 2
4 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 37749074
Personally, I think that if the events have more in common with each other than not, then you need to create generic ways to deal them.  That would include Event class, Registration class, and probably a generic registration form to handle individual registrations for all events.

Coming up with methods to deal with the ways that events are different from one another is the really challenging part of this.
0
 
LVL 7

Author Comment

by:MHenry
ID: 37749599
PaulHews,

That makes sense.

The main difference between events is date, time, vendors involved and description.

And the people involved always want to see a list of registrations and get an email notification when someone does register.

Any ideas to give me a head start?

Thanks,
mh
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 37749746
The main difference between events is date, time, vendors involved and description.
Sounds to me like you are describing fields.

So lets say you have an event class, with fields:

Event:
ID
Title (or Name)
EventDateTime
Vendors  (Note that this may require more classes and links)
Description

This could map to a database table.

Now each event has multiple registrations:

Registration:
ID
EventID (This links to the unique ID in the event table)
Email
FirstName
LastName

This also maps to a database table.  

Your generic sign up form would be populated by pulling the event record from the database and displaying it with areas where you can enter your information if you wish to register.

Of course the model gets more complicated if people sign up for multiple events, in which case you might have another table/class mapping.

You can use tools like Entity Framework or NHibernate or other ORMs to map back and forth from database to classes.  There are lots of tutorials on this.  
eg
http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

Properly modeling your data is important.
0
 
LVL 7

Author Comment

by:MHenry
ID: 37749873
PaulHews,

This ought to be carved in stone rather than buried at the end of your post:
"Properly modeling your data is important." Gave me a good chuckle to see that. When you've been doing it for years, it may seem like that. To me, it's scary as hell. I've been putting this off for months because I was afraid to even start.

This was exactly the kind of thing I was looking for. I couldn't see how making it one class would work. And when you said, "This looks like fields," it was like a light came on.

Well done sir. And my thanks!
mh
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now