Solved

Create a class for registrations or not? asp.net

Posted on 2012-03-21
4
342 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

21 Experts available now in Live!

Get 1:1 Help Now