public ActionResult AddOrganization(OrgVM o) { IHeroRepo herorepo = HeroRepoFactory.Create(); IOrgRepo orgrepo = OrgRepoFactory.Create(); if (ModelState.IsValid) { o.OrganizationHeroes = new List <Hero>(); var org = new Organization { SelectedHeroesID = o.SelectedHeroesID, OrganizationID = o.OrganizationID, OrganizationName = o.OrganizationName, OganizationAddress = o.OganizationAddress, OrganizationLocation = o.OrganizationLocation, Phone = o.Phone, }; foreach (var HeroID in o.SelectedHeroesID) { org.OrganizationHeroes.Add(herorepo.GetHereosByID(HeroID)); } orgrepo.AddOrganization(org); } else { return(View(o)); } return(RedirectToAction("OrganizationList")); }