public PartialViewResult EditMatchMakerKeywordsModal(OrganizationPrimaryKey organizationPrimaryKey) { var organization = organizationPrimaryKey.EntityObject; var viewModel = new MatchmakerKeywordsModalViewModel(organization); var viewData = new MatchmakerKeywordsModalViewData(organization); return(RazorPartialView <MatchmakerKeywordsModal, MatchmakerKeywordsModalViewData, MatchmakerKeywordsModalViewModel>(viewData, viewModel)); }
public ActionResult EditMatchMakerKeywordsModal(OrganizationPrimaryKey organizationPrimaryKey, MatchmakerKeywordsModalViewModel viewModel) { var organization = organizationPrimaryKey.EntityObject; if (!ModelState.IsValid) { var viewData = new MatchmakerKeywordsModalViewData(organization); return(RazorPartialView <MatchmakerKeywordsModal, MatchmakerKeywordsModalViewData, MatchmakerKeywordsModalViewModel>(viewData, viewModel)); } viewModel.UpdateModel(organization, HttpRequestStorage.DatabaseEntities, CurrentFirmaSession); HttpRequestStorage.DatabaseEntities.SaveChanges(); // Clean up any orphaned MatchmakerKeywords (just for this Tenant) var orphanedMatchmakerKeywords = HttpRequestStorage.DatabaseEntities.MatchmakerKeywords .Where(mk => !mk.OrganizationMatchmakerKeywords.Any()).ToList(); orphanedMatchmakerKeywords.ForEach(omk => omk.Delete(HttpRequestStorage.DatabaseEntities)); HttpRequestStorage.DatabaseEntities.SaveChanges(); return(new ModalDialogFormJsonResult(SitkaRoute <OrganizationController> .BuildUrlFromExpression(x => x.Detail(organization, OrganizationDetailViewData.OrganizationDetailTab.Profile)))); }