Solved

How To Add Multiple Family Members

Posted on 2015-01-20
9
118 Views
Last Modified: 2015-02-02
I need a web form that will allow the insert of  family information and then Family Members information. The form needs to collect several family members for a multiple child insert. For example the family "Jones" has members named "Tom", "Felix", "Alicia", "Constance", and "Philip". These all need to be inserted in a single transaction. I have been trying to figure out how to use MVC 5 and Entityframework, and I have tried to figure out how to use Webforms. It seems I need to store the names in a list of some kind and then using "save changes()" insert them into the database tables shown in a picture below. I have looked a several tutorials, but it seems that no one has an need to demonstrate how to achieve this in one. I can't figure out which technology EF or Webforms is the easiest and/or the best way to go, but I am frustrated. Can I get some help with this seemingly straight forward problem?

A set of parent/child tables.
0
Comment
Question by:wdarnellg
  • 6
  • 2
9 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
So are you asking us to do the work for you, or did you have a specific question that is troubling you? Perhaps if you post the code you tried and any error messages or incorrect behavior you observe?
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Hi wdarnellg;

To your statement, "I have been trying to figure out how to use MVC 5 and Entity Framework", On the Microsoft ASP.NET MVC web site you will find many learning resources, here is a 10 part tutorial on what you wish to do, Creating an Entity Framework Data Model for an ASP.NET MVC Application (1 of 10), and when you have gone through the 10 tutorials you can ask some questions on what you may still not understand. If you have any specific questions please ask.
0
 

Author Comment

by:wdarnellg
Comment Utility
I apologize for being so vague.
I just want help in understanding how to combine the create views or forms of the families and individuals to make a single form that will insert both the Family then the Individual records. The child portion of the form may or may not have more than one or two records to be added. Some families may add up to 6 or 7 family members.
I honestly don't wish to have anyone really do the project for me. There is still validation and some business logic to add to this even though It is an input only app. I would just like to see a working example of creating a new "parent" record, and then adding multiple 'child' records to the transaction on a single form, wizard, or however something like this can work best.

The mvc Create Code I am looking at:


        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Id,FamilyName,PhoneNumber,Email,Address1,Address2,City,State,ZipCode,MyPreferedSite,FamilyIncome,RowVersion")] Families families) 
        {
            if (ModelState.IsValid)
            {
                db.Families.Add(families);
// I am guessing that some kind of way to get a family Id would go here
// I am guessing that some kind of Individuals collections or lists would go here with the new family id.
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(families);
        }

Open in new window


But how to create the Family ID and HOW to create the list of Individuals.

I would love a tutorial, or some kind of guide that will address this kind of scenario kind of head on, if one exists.

I did a small application similar to this using Lightswitch. It made this kind of parent child collection/insertion quite easy... perhaps too easy as it all worked behind the scenes.. Lightswitch doesn't play very well with non-Microsoft products like iPads etc... so my project became impractical for the group I have to work with.
I am not a professional programmer, so I am trying my best here.

Thanks for the patience.  :-)
0
 

Author Comment

by:wdarnellg
Comment Utility
Thanks Fernando. I did the Contoso University tutorial and it is very good and helpful, except that it doesn't address the kind of UI I am talking about. It shows how to create related records of course, but it does it one entity at a time, and different insert operations. The example I seek will show how to create a "parent" and "multiple children" in a single transaction.
:-) It seems ironic to me that in a world of parent-children records, that I struggle with records of actual parents and children.
Per your suggestion, I am reviewing the database first version of Contoso University: http://www.asp.net/mvc/overview/getting-started/database-first-development/setting-up-database
I am probably missed something.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
To confirm, what technologies are you using? It sounds like you've now decided on MVC and Entity Framework. Is that correct?
0
 

Author Comment

by:wdarnellg
Comment Utility
Hi kaufmed.
I think for the moment anyway, I will pursue trying to understand if and how mvc/ef will work. However, (and please forgive me if I continue to seem vague), if there is a webforms example to look at, I am very open to looking at it or them if more than one.
0
 

Accepted Solution

by:
wdarnellg earned 0 total points
Comment Utility
I found a course on Pluralsight that addresses parent child records using EF. It also brings in Knockout, ajax, and mvc.
http://www.pluralsight.com/courses/parent-child-data-ef-mvc-knockout-ajax
This has me moving in the right direction.
Thanks for trying.
0
 

Author Comment

by:wdarnellg
Comment Utility
I thought I would add one last comment to this question. As stated in my previous post, the course found at http://www.pluralsight.com/courses/parent-child-data-ef-mvc-knockout-ajax is pretty much exactly what I was seeking in terms of creating parent with multiple children records in a single transaction. I must say that this is NOT an easy task. If you are inexperienced at this as I am, the course is a wonderful step by step. But even the course instructor states his disappointment in the lack of documentation and tutorials on what seems like a pretty basic need for collecting data. I am finding the learning curve worth the time and I encourage anyone this may help to hang in there.
I am sure there are other solutions, maybe even easier ones, but this one is at least findable and well demonstrated.
Good Luck,
wdg
0
 

Author Closing Comment

by:wdarnellg
Comment Utility
I couldn't seem to ask the right question to get any guidance. I wanted ANY help possible using ANY technology that would get me a simple input web app. I guess my question was just too vague. I found some help with the Pluralsight.com course by Adam Churvis.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

744 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

16 Experts available now in Live!

Get 1:1 Help Now