Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8560721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:20:30+00:00 2026-06-11T16:20:30+00:00

I have a page that is used to register people for training. The current

  • 0

I have a page that is used to register people for training. The current page has three drop downs on it, one to select the person to register, one to select the course, and one to select the session that the course is offered. It is being requested that the page be modified to now have four groups of the Course and Session drop downs to allow for the user to register up to four classes for a person at a time. My problem arises on how to handle the form posting now. Before if a user tried to add a person to a course they were already registered for the Entity Framework model binding would catch the error and send the error message back to the form. I’m not sure how to implement this binding now that there are four instances to evaluate and save at the same time. I’m a newbie to MVC and EF so any help/direction would greatly be appreciated.

Edit: below is a piece of the orignial controller save function:

    var AddToCourse = new Session_Registrant()
{
    RegistrantID = RegistrantID,
    SessionID = Session1,
    RegistrantOrg = regOrg,
    RegistrantTitle = title,
    RegistedDate = DateTime.Now

};
//attempt to save
try
{
    if (ModelState.IsValid)
    {
        db.AddToSession_Registrant(AddToCourse);
        db.SaveChanges();
    }
}
catch (DataException error)
{
    if (error.InnerException != null)
    {
        if (error.InnerException.Message.Contains("UNIQUE KEY constraint"))
        {
            //adding custom error message to explain the failure
            ModelState.AddModelError("", "Error! Registrant has already been added to this course session.");
        }
    }
    else
    {
        ModelState.AddModelError("Error", error.Message);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:20:31+00:00Added an answer on June 11, 2026 at 4:20 pm

    I wonder if the problem is with the design of the function rather than the implementation. Should the problem be defined in terms of a one-to-many relationship between the registrant entity and the course/session entity.

    I am also of the view that using exceptions as part of the design is bad practice and that this is a definition problem. Should you (your code) be asking questions like:

    • Is this a registered student
    • Does this student have a course already booked in this session
    • Is this student already registered on the course in a different session

    In other words define your business rules, implement them and the problem should resolve itself into a SMOC (small matter of coding).

    I am sorry if this response is not more directly helpful but I feel that this is the wrong starting point. Good luck anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have n number of select elements in an html page that are used
I have a JSP page that has 2 forms running on Tomcat 6. One
I have a page that allows for used input, when the user inputs his/her
I'm have a page that will be used (and hence styled) only for printing.
I have a page that will basically be used to concatenate a bunch of
What I have: I have a generic JSP page that is used throughout my
I am making a web page in that I have used Ajax calendar to
I have a module that is being used to create only a few page
I have page register.php, which is used to get user informations, after completion of
I have a web page that used client side templating to update part of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.