Create a class for registrations or not? asp.net

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
LVL 7
MHenryAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PaulHewsCommented:
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
MHenryAuthor Commented:
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
PaulHewsCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MHenryAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.