Solved

Create a class for registrations or not? asp.net

Posted on 2012-03-21
4
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp.net uploading picture to a temporary folder 4 25
Data organization issue 7 37
asp.net figure out error 3 24
How to escape alias names for Oracle query 1 25
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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