public ActionResult CreateFamily(CreateFamilyProfile viewModel) { if (!ModelState.IsValid) { ViewBag.Message = "Error. Object is not valid"; return View(viewModel); } var family = new Family() { ParentFirstName = viewModel.ParentFirstName, ParentLastName = viewModel.ParentLastName, Shipping_address = viewModel.Shipping_address, Shipping_city = viewModel.Shipping_city, Shipping_state = viewModel.Shipping_state, Shipping_zipCode = viewModel.Shipping_zipCode, Phone = viewModel.Phone, Email = viewModel.Email }; var child = new Child() { Family_ID = viewModel.Family_ID, Child_FirstName = viewModel.Child_FirstName, Child_LastName = viewModel.Child_LastName, Age = viewModel.Age, Gender = viewModel.Gender }; db.Families.Add(family); db.Children.Add(child); db.SaveChanges(); TempData["Message"] = "Family and Child added successfully"; return RedirectToAction("CreateFamily"); }
public ActionResult CreateFamily() { var viewModel = new CreateFamilyProfile(); return View(); }