public ActionResult EditOrganization(OrgVM o) { ILocationRepo locorepo = LocationRepoFactory.Create(); IHeroRepo herorepo = HeroRepoFactory.Create(); IOrgRepo orgrepo = OrgRepoFactory.Create(); if (ModelState.IsValid) { o.OrganizationHeroes = new List <Hero>(); var orgToEdit = new Organization { OrganizationID = o.OrganizationID, OganizationAddress = o.OganizationAddress, OrganizationLocation = locorepo.GetLocationById(o.OrganizationLocation.LocationID), OrganizationName = o.OrganizationName, Phone = o.Phone, }; foreach (var HeroID in o.SelectedHeroesID) { orgToEdit.OrganizationHeroes.Add(herorepo.GetHereosByID(HeroID)); } orgrepo.EditOrg(orgToEdit); } return(RedirectToAction("OrganizationList")); }