本文整理汇总了C#中Rock.Model.GroupMemberService.Save方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMemberService.Save方法的具体用法?C# GroupMemberService.Save怎么用?C# GroupMemberService.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupMemberService
的用法示例。
在下文中一共展示了GroupMemberService.Save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInit
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnInit( EventArgs e )
{
base.OnInit( e );
try
{
string groupMemberKey = PageParameter( "gm" );
if ( string.IsNullOrWhiteSpace( groupMemberKey ) )
{
ShowError( "Missing Parameter Value" );
}
else
{
var groupMemberService = new GroupMemberService();
var groupMember = groupMemberService.GetByUrlEncodedKey( PageParameter( "gm" ) );
if ( groupMember == null )
{
ShowError();
}
else
{
groupMember.GroupMemberStatus = GroupMemberStatus.Active;
groupMemberService.Save( groupMember, CurrentPersonId );
nbMessage.NotificationBoxType = NotificationBoxType.Success;
nbMessage.Title = "Success";
nbMessage.Text = GetAttributeValue( "SuccessMessage" );
}
}
}
catch (SystemException ex)
{
ShowError( ex.Message );
}
}
示例2: btnSave_Click
/// <summary>
/// Handles the Click event of the btnSave 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 btnSave_Click( object sender, EventArgs e )
{
// confirmation was disabled by btnSave on client-side. So if returning without a redirect,
// it should be enabled. If returning with a redirect, the control won't be updated to reflect
// confirmation being enabled, so it's ok to enable it here
confirmExit.Enabled = true;
if ( Page.IsValid )
{
confirmExit.Enabled = true;
RockTransactionScope.WrapTransaction( () =>
{
using ( new UnitOfWorkScope() )
{
var familyService = new GroupService();
var familyMemberService = new GroupMemberService();
var personService = new PersonService();
var historyService = new HistoryService();
var familyChanges = new List<string>();
// SAVE FAMILY
_family = familyService.Get( _family.Id );
History.EvaluateChange( familyChanges, "Name", _family.Name, tbFamilyName.Text );
_family.Name = tbFamilyName.Text;
int? campusId = cpCampus.SelectedValueAsInt();
if ( _family.CampusId != campusId )
{
History.EvaluateChange( familyChanges, "Campus",
_family.CampusId.HasValue ? CampusCache.Read( _family.CampusId.Value ).Name : string.Empty,
campusId.HasValue ? CampusCache.Read( campusId.Value ).Name : string.Empty );
_family.CampusId = campusId;
}
var familyGroupTypeId = _family.GroupTypeId;
familyService.Save( _family, CurrentPersonId );
// SAVE FAMILY MEMBERS
int? recordStatusValueID = ddlRecordStatus.SelectedValueAsInt();
int? reasonValueId = ddlReason.SelectedValueAsInt();
var newFamilies = new List<Group>();
foreach ( var familyMember in FamilyMembers )
{
var memberChanges = new List<string>();
var demographicChanges = new List<string>();
var role = familyRoles.Where( r => r.Guid.Equals( familyMember.RoleGuid ) ).FirstOrDefault();
if ( role == null )
{
role = familyRoles.FirstOrDefault();
}
bool isChild = role != null && role.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD ) );
// People added to family (new or from other family)
if ( !familyMember.ExistingFamilyMember )
{
var groupMember = new GroupMember();
if ( familyMember.Id == -1 )
{
// added new person
demographicChanges.Add( "Created" );
var person = new Person();
person.FirstName = familyMember.FirstName;
History.EvaluateChange( demographicChanges, "First Name", string.Empty, person.FirstName );
person.LastName = familyMember.LastName;
History.EvaluateChange( demographicChanges, "Last Name", string.Empty, person.LastName );
person.Gender = familyMember.Gender;
History.EvaluateChange( demographicChanges, "Gender", null, person.Gender );
person.BirthDate = familyMember.BirthDate;
History.EvaluateChange( demographicChanges, "Birth Date", null, person.BirthDate );
if ( !isChild )
{
person.GivingGroupId = _family.Id;
History.EvaluateChange( demographicChanges, "Giving Group", string.Empty, _family.Name );
}
groupMember.Person = person;
}
else
{
// added from other family
groupMember.Person = personService.Get( familyMember.Id );
//.........这里部分代码省略.........
示例3: DeleteGroupMember_Click
/// <summary>
/// Handles the Click event of the DeleteGroupMember control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param>
protected void DeleteGroupMember_Click( object sender, Rock.Web.UI.Controls.RowEventArgs e )
{
RockTransactionScope.WrapTransaction( () =>
{
GroupMemberService groupMemberService = new GroupMemberService();
GroupMember groupMember = groupMemberService.Get( e.RowKeyId );
if ( groupMember != null )
{
string errorMessage;
if ( !groupMemberService.CanDelete( groupMember, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Information );
return;
}
int groupId = groupMember.GroupId;
groupMemberService.Delete( groupMember, CurrentPersonId );
groupMemberService.Save( groupMember, CurrentPersonId );
Group group = new GroupService().Get( groupId );
if ( group.IsSecurityRole || group.GroupType.Guid.Equals(Rock.SystemGuid.GroupType.GROUPTYPE_SECURITY_ROLE.AsGuid() ))
{
// person removed from SecurityRole, Flush
Rock.Security.Role.Flush( group.Id );
Rock.Security.Authorization.Flush();
}
}
} );
BindGroupMembersGrid();
}
示例4: modalAddPerson_SaveClick
void modalAddPerson_SaveClick( object sender, EventArgs e )
{
if (!string.IsNullOrWhiteSpace(acPerson.Value))
{
int personId = int.MinValue;
if ( int.TryParse( acPerson.Value, out personId ) )
{
int? roleId = grpRole.GroupRoleId;
if ( roleId.HasValue )
{
using ( new UnitOfWorkScope() )
{
var memberService = new GroupMemberService();
var group = memberService.Queryable()
.Where( m =>
m.PersonId == Person.Id &&
m.GroupRole.Guid == ownerRoleGuid
)
.Select( m => m.Group )
.FirstOrDefault();
if ( group != null )
{
var groupMember = memberService.Queryable()
.Where( m =>
m.GroupId == group.Id &&
m.PersonId == personId &&
m.GroupRoleId == roleId.Value )
.FirstOrDefault();
if ( groupMember == null )
{
groupMember = new GroupMember();
groupMember.GroupId = group.Id;
groupMember.PersonId = personId;
groupMember.GroupRoleId = roleId.Value;
memberService.Add( groupMember, CurrentPersonId );
}
memberService.Save( groupMember, CurrentPersonId );
if ( IsKnownRelationships )
{
var inverseGroupMember = memberService.GetInverseRelationship(
groupMember, bool.Parse( GetAttributeValue( "CreateGroup" ) ), CurrentPersonId );
if ( inverseGroupMember != null )
{
memberService.Save( inverseGroupMember, CurrentPersonId );
}
}
}
}
}
}
}
BindData();
}
示例5: rGroupMembers_ItemCommand
void rGroupMembers_ItemCommand( object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e )
{
int groupMemberId = int.MinValue;
if ( int.TryParse( e.CommandArgument.ToString(), out groupMemberId ) )
{
var service = new GroupMemberService();
var groupMember = service.Get( groupMemberId );
if ( groupMember != null )
{
if ( e.CommandName == "EditRole" )
{
ShowModal(groupMember.Person, groupMember.GroupRoleId);
}
else if ( e.CommandName == "RemoveRole" )
{
if ( IsKnownRelationships )
{
var inverseGroupMember = service.GetInverseRelationship( groupMember, false, CurrentPersonId );
if ( inverseGroupMember != null )
{
service.Delete( inverseGroupMember, CurrentPersonId );
}
}
service.Delete( groupMember, CurrentPersonId );
service.Save( groupMember, CurrentPersonId );
BindData();
}
}
}
}
示例6: Execute
/// <summary>
/// Executes the specified workflow.
/// </summary>
/// <param name="action">The workflow action.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">The error messages.</param>
/// <returns></returns>
/// <exception cref="System.NotImplementedException"></exception>
public override bool Execute( Model.WorkflowAction action, Object entity, out List<string> errorMessages )
{
var checkInState = GetCheckInState( entity, out errorMessages );
if ( checkInState != null )
{
DateTime startDateTime = DateTime.Now;
int securityCodeLength = 3;
if ( !int.TryParse( GetAttributeValue( action, "SecurityCodeLength" ), out securityCodeLength ) )
{
securityCodeLength = 3;
}
using ( var uow = new Rock.Data.UnitOfWorkScope() )
{
var attendanceCodeService = new AttendanceCodeService();
var attendanceService = new AttendanceService();
var groupMemberService = new GroupMemberService();
foreach ( var family in checkInState.CheckIn.Families.Where( f => f.Selected ) )
{
foreach ( var person in family.People.Where( p => p.Selected ) )
{
var attendanceCode = attendanceCodeService.GetNew( securityCodeLength );
person.SecurityCode = attendanceCode.Code;
foreach ( var groupType in person.GroupTypes.Where( g => g.Selected ) )
{
foreach ( var group in groupType.Groups.Where( g => g.Selected ) )
{
foreach ( var location in group.Locations.Where( l => l.Selected ) )
{
if ( groupType.GroupType.AttendanceRule == AttendanceRule.AddOnCheckIn &&
groupType.GroupType.DefaultGroupRoleId.HasValue &&
!groupMemberService.GetByGroupIdAndPersonId( group.Group.Id, person.Person.Id, true ).Any() )
{
var groupMember = new GroupMember();
groupMember.GroupId = group.Group.Id;
groupMember.PersonId = person.Person.Id;
groupMember.GroupRoleId = groupType.GroupType.DefaultGroupRoleId.Value;
groupMemberService.Add( groupMember, null );
groupMemberService.Save( groupMember, null );
}
foreach ( var schedule in location.Schedules.Where( s => s.Selected ) )
{
// Only create one attendance record per day for each person/schedule/group/location
var attendance = attendanceService.Get( startDateTime, location.Location.Id, schedule.Schedule.Id, group.Group.Id, person.Person.Id );
if ( attendance == null )
{
attendance = ((Rock.Data.RockContext)uow.DbContext).Attendances.Create();
attendance.LocationId = location.Location.Id;
attendance.ScheduleId = schedule.Schedule.Id;
attendance.GroupId = group.Group.Id;
attendance.PersonId = person.Person.Id;
attendance.DeviceId = checkInState.Kiosk.Device.Id;
attendance.SearchTypeValueId = checkInState.CheckIn.SearchType.Id;
attendanceService.Add( attendance, null );
}
attendance.AttendanceCodeId = attendanceCode.Id;
attendance.StartDateTime = startDateTime;
attendance.EndDateTime = null;
attendance.DidAttend = true;
attendanceService.Save( attendance, null );
KioskLocationAttendance.AddAttendance( attendance );
}
}
}
}
}
}
}
return true;
}
return false;
}
示例7: AddGroupMember
/// <summary>
/// Adds the group member.
/// </summary>
/// <param name="familyGroup">The family group.</param>
/// <param name="person">The person.</param>
/// <returns></returns>
protected GroupMember AddGroupMember( int familyGroupId, Person person )
{
GroupMember groupMember = new GroupMember().Clone( false );
GroupMemberService groupMemberService = new GroupMemberService();
groupMember.IsSystem = false;
groupMember.GroupId = familyGroupId;
groupMember.PersonId = person.Id;
if ( person.Age >= 18 )
{
groupMember.GroupRoleId = new GroupTypeRoleService().Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ).Id;
}
else
{
groupMember.GroupRoleId = new GroupTypeRoleService().Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD ) ).Id;
}
Rock.Data.RockTransactionScope.WrapTransaction( () =>
{
groupMemberService.Add( groupMember, CurrentPersonId );
groupMemberService.Save( groupMember, CurrentPersonId );
} );
return groupMember;
}
示例8: rGridPersonResults_AddExistingPerson
/// <summary>
/// Handles the RowCommand event of the grdPersonSearchResults control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="GridViewCommandEventArgs"/> instance containing the event data.</param>
protected void rGridPersonResults_AddExistingPerson( object sender, GridViewCommandEventArgs e )
{
if ( e.CommandName == "Add" )
{
GroupMemberService groupMemberService = new GroupMemberService();
int index = int.Parse( e.CommandArgument.ToString() );
int personId = int.Parse( rGridPersonResults.DataKeys[index].Value.ToString() );
var family = CurrentCheckInState.CheckIn.Families.Where( f => f.Selected ).FirstOrDefault();
if ( family != null )
{
var checkInPerson = new CheckInPerson();
checkInPerson.Person = new PersonService().Get( personId ).Clone( false );
var isPersonInFamily = family.People.Any( p => p.Person.Id == checkInPerson.Person.Id );
if ( !isPersonInFamily )
{
if ( personVisitorType.Value != "Visitor" )
{
var groupMember = groupMemberService.GetByPersonId( personId ).FirstOrDefault();
groupMember.GroupId = family.Group.Id;
Rock.Data.RockTransactionScope.WrapTransaction( () =>
{
groupMemberService.Save( groupMember, CurrentPersonId );
} );
checkInPerson.FamilyMember = true;
hfSelectedPerson.Value += personId + ",";
}
else
{
AddVisitorGroupMemberRoles( family, personId );
checkInPerson.FamilyMember = false;
hfSelectedVisitor.Value += personId + ",";
}
checkInPerson.Selected = true;
family.People.Add( checkInPerson );
ProcessFamily();
}
mpeAddPerson.Hide();
}
else
{
string errorMsg = "<ul><li>You have to pick a family to add this person to.</li></ul>";
maWarning.Show( errorMsg, Rock.Web.UI.Controls.ModalAlertType.Warning );
}
}
else
{
mpeAddPerson.Show();
BindPersonGrid();
}
}
示例9: btnSave_Click
protected void btnSave_Click( object sender, EventArgs e )
{
if ( string.IsNullOrWhiteSpace( txtFirstName.Text ) ||
string.IsNullOrWhiteSpace( txtLastName.Text ) ||
string.IsNullOrWhiteSpace( txtEmail.Text ) )
{
ShowError( "Missing Information", "Please enter a value for First Name, Last Name, and Email" );
}
else
{
var person = GetPerson();
if ( person != null )
{
int groupId = int.MinValue;
if ( int.TryParse( GetAttributeValue( "Group" ), out groupId ) )
{
using ( new UnitOfWorkScope() )
{
var groupService = new GroupService();
var groupMemberService = new GroupMemberService();
var group = groupService.Get( groupId );
if ( group != null && group.GroupType.DefaultGroupRoleId.HasValue )
{
string linkedPage = GetAttributeValue( "ConfirmationPage" );
if ( !string.IsNullOrWhiteSpace( linkedPage ) )
{
var member = group.Members.Where( m => m.PersonId == person.Id ).FirstOrDefault();
// If person has not registered or confirmed their registration
if ( member == null || member.GroupMemberStatus != GroupMemberStatus.Active )
{
Email email = null;
Guid guid = Guid.Empty;
if ( Guid.TryParse( GetAttributeValue( "ConfirmationEmail" ), out guid ) )
{
email = new Email( guid );
}
if ( member == null )
{
member = new GroupMember();
member.GroupId = group.Id;
member.PersonId = person.Id;
member.GroupRoleId = group.GroupType.DefaultGroupRoleId.Value;
// If a confirmation email is configured, set status to Pending otherwise set it to active
member.GroupMemberStatus = email != null ? GroupMemberStatus.Pending : GroupMemberStatus.Active;
groupMemberService.Add( member, CurrentPersonId );
groupMemberService.Save( member, CurrentPersonId );
member = groupMemberService.Get( member.Id );
}
// Send the confirmation
if ( email != null )
{
var mergeObjects = new Dictionary<string, object>();
mergeObjects.Add( "Member", member );
var pageParams = new Dictionary<string, string>();
pageParams.Add( "gm", member.UrlEncodedKey );
var pageReference = new Rock.Web.PageReference( linkedPage, pageParams );
mergeObjects.Add( "ConfirmationPage", pageReference.BuildUrl() );
var recipients = new Dictionary<string, Dictionary<string, object>>();
recipients.Add( person.Email, mergeObjects );
email.Send( recipients );
}
ShowSuccess( GetAttributeValue( "SuccessMessage" ) );
}
else
{
var pageParams = new Dictionary<string, string>();
pageParams.Add( "gm", member.UrlEncodedKey );
var pageReference = new Rock.Web.PageReference( linkedPage, pageParams );
Response.Redirect( pageReference.BuildUrl(), false );
}
}
else
{
ShowError( "Configuration Error", "Invalid Confirmation Page setting" );
}
}
else
{
ShowError( "Configuration Error",
"The configured group does not exist, or it's group type does not have a default role configured." );
}
}
}
else
{
ShowError( "Configuration Error", "Invalid Group setting" );
}
}
}
//.........这里部分代码省略.........