/// <summary> /// Handles the SaveClick event of the mdLinkConversation control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void mdLinkToPerson_SaveClick(object sender, EventArgs e) { using (var rockContext = new RockContext()) { var personAliasService = new PersonAliasService(rockContext); var personService = new PersonService(rockContext); // Get the Person Record from the selected conversation. (It should be a 'NamelessPerson' record type) int namelessPersonAliasId = hfSelectedRecipientPersonAliasId.Value.AsInteger(); var phoneNumberService = new PhoneNumberService(rockContext); Person namelessPerson = personAliasService.GetPerson(namelessPersonAliasId); if (namelessPerson == null) { // shouldn't happen, but just in case return; } EntitySet mergeRequest = null; if (pnlLinkToExistingPerson.Visible) { var existingPersonId = ppPerson.PersonId; if (!existingPersonId.HasValue) { return; } var existingPerson = personService.Get(existingPersonId.Value); mergeRequest = namelessPerson.CreateMergeRequest(existingPerson); var entitySetService = new EntitySetService(rockContext); entitySetService.Add(mergeRequest); rockContext.SaveChanges(); hfSelectedRecipientPersonAliasId.Value = existingPerson.PrimaryAliasId.ToString(); } else { // new Person and new family var newPerson = new Person(); newPersonEditor.UpdatePerson(newPerson, rockContext); personService.Add(newPerson); rockContext.SaveChanges(); mergeRequest = namelessPerson.CreateMergeRequest(newPerson); var entitySetService = new EntitySetService(rockContext); entitySetService.Add(mergeRequest); rockContext.SaveChanges(); hfSelectedRecipientPersonAliasId.Value = newPerson.PrimaryAliasId.ToString(); } RedirectToMergeRequest(mergeRequest); } mdLinkToPerson.Hide(); LoadResponseListing(); }
/// <summary> /// Handles the SaveClick event of the mdLinkToPerson control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void mdLinkToPerson_SaveClick(object sender, EventArgs e) { using (var rockContext = new RockContext()) { var personAliasService = new PersonAliasService(rockContext); var personService = new PersonService(rockContext); int namelessPersonId = hfNamelessPersonId.Value.AsInteger(); Person namelessPerson = personService.Get(namelessPersonId); if (namelessPerson == null) { // shouldn't happen, but just in case return; } EntitySet mergeRequest = null; if (pnlLinkToExistingPerson.Visible) { var existingPersonId = ppPerson.PersonId; if (!existingPersonId.HasValue) { return; } var existingPerson = personService.Get(existingPersonId.Value); mergeRequest = namelessPerson.CreateMergeRequest(existingPerson); var entitySetService = new EntitySetService(rockContext); entitySetService.Add(mergeRequest); rockContext.SaveChanges(); } else { // new Person and new family var newPerson = new Person(); newPersonEditor.UpdatePerson(newPerson, rockContext); personService.Add(newPerson); rockContext.SaveChanges(); mergeRequest = namelessPerson.CreateMergeRequest(newPerson); var entitySetService = new EntitySetService(rockContext); entitySetService.Add(mergeRequest); rockContext.SaveChanges(); } RedirectToMergeRequest(mergeRequest); } mdLinkToPerson.Hide(); BindGrid(); }
private void Actions_BulkUpdateClick(object sender, EventArgs e) { var items = gWorkflows.SelectedKeys.Select(s => ( int )s).ToList(); if (!items.Any()) { var dataKeyArray = gWorkflows.DataKeys; foreach (DataKey dataKey in dataKeyArray) { items.Add(( int )dataKey.Value); } } if (!items.Any()) { return; } RockContext rockContext = new RockContext(); EntitySetService entitySetService = new EntitySetService(rockContext); EntitySet entitySet = new EntitySet { EntityTypeId = EntityTypeCache.GetId(typeof(Workflow)), ExpireDateTime = RockDateTime.Now.AddDays(1) }; entitySetService.Add(entitySet); foreach (var item in items) { var entitySetItem = new EntitySetItem() { EntityId = item, }; entitySet.Items.Add(entitySetItem); } rockContext.SaveChanges(); NavigateToLinkedPage("UpdatePage", new Dictionary <string, string> { { "EntitySetId", entitySet.Id.ToString() } }); }