public ActionResult CreateCompany(CreateCompanyVM vm) { if (ModelState.IsValid) { var addressModel = new Address { Street = vm.Street, City = vm.City, State = vm.State, Zipcode = vm.Zipcode }; int addressID = context.CreateAddress(addressModel); //DRJ - want to attach addressID to company on company creation var companyModel = new Company { CompanyName = vm.CompanyName, AddressID = addressID }; context.SaveCompany(companyModel); return RedirectToAction("CreateEmployee",new { company = vm.CompanyName } ); } //DRJ - need to repopulate to avoid error vm.StateList = context.States .OrderBy(s => s.Abbreviation) .Select(s => new SelectListItem { Text = s.Name, Value = s.Abbreviation }); return View(vm); }
public ActionResult CreateCompany() { var model = new CreateCompanyVM(context.States); return View(model); }