本文整理汇总了C#中Rock.Model.PersonAliasService.GetPrimaryAliasId方法的典型用法代码示例。如果您正苦于以下问题:C# PersonAliasService.GetPrimaryAliasId方法的具体用法?C# PersonAliasService.GetPrimaryAliasId怎么用?C# PersonAliasService.GetPrimaryAliasId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonAliasService
的用法示例。
在下文中一共展示了PersonAliasService.GetPrimaryAliasId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: lbSave_Click
/// <summary>
/// Handles the Click event of the lbSave 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 lbSave_Click( object sender, EventArgs e )
{
if ( _group != null && _occurrence != null )
{
var rockContext = new RockContext();
var attendanceService = new AttendanceService( rockContext );
var personAliasService = new PersonAliasService( rockContext );
var locationService = new LocationService( rockContext );
bool dateAdjusted = false;
DateTime startDate = _occurrence.Date;
// If this is a manuall entered occurrence, check to see if date was changed
if ( !_occurrence.ScheduleId.HasValue )
{
DateTime? originalDate = PageParameter( "Date" ).AsDateTime();
if ( originalDate.HasValue && originalDate.Value.Date != startDate.Date )
{
startDate = originalDate.Value.Date;
dateAdjusted = true;
}
}
DateTime endDate = startDate.AddDays( 1 );
var existingAttendees = attendanceService
.Queryable( "PersonAlias" )
.Where( a =>
a.GroupId == _group.Id &&
a.LocationId == _occurrence.LocationId &&
a.ScheduleId == _occurrence.ScheduleId &&
a.StartDateTime >= startDate &&
a.StartDateTime < endDate );
if ( dateAdjusted )
{
foreach ( var attendee in existingAttendees )
{
attendee.StartDateTime = _occurrence.Date;
}
}
// If did not meet was selected and this was a manually entered occurrence (not based on a schedule/location)
// then just delete all the attendance records instead of tracking a 'did not meet' value
if ( cbDidNotMeet.Checked && !_occurrence.ScheduleId.HasValue )
{
foreach ( var attendance in existingAttendees )
{
attendanceService.Delete( attendance );
}
}
else
{
int? campusId = locationService.GetCampusIdForLocation( _occurrence.LocationId );
if ( !campusId.HasValue )
{
campusId = _group.CampusId;
}
if ( !campusId.HasValue && _allowCampusFilter )
{
var campus = CampusCache.Read( bddlCampus.SelectedValueAsInt() ?? 0 );
if ( campus != null )
{
campusId = campus.Id;
}
}
if ( cbDidNotMeet.Checked )
{
// If the occurrence is based on a schedule, set the did not meet flags
foreach ( var attendance in existingAttendees )
{
attendance.DidAttend = null;
attendance.DidNotOccur = true;
}
}
foreach ( var attendee in _attendees )
{
var attendance = existingAttendees
.Where( a => a.PersonAlias.PersonId == attendee.PersonId )
.FirstOrDefault();
if ( attendance == null )
{
int? personAliasId = personAliasService.GetPrimaryAliasId( attendee.PersonId );
if ( personAliasId.HasValue )
{
attendance = new Attendance();
attendance.GroupId = _group.Id;
attendance.ScheduleId = _group.ScheduleId;
attendance.PersonAliasId = personAliasId;
attendance.StartDateTime = _occurrence.Date.Date.Add( _occurrence.StartTime );
attendance.LocationId = _occurrence.LocationId;
attendance.CampusId = campusId;
//.........这里部分代码省略.........
示例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 )
{
if ( ! ppRequestor.PersonAliasId.HasValue )
{
ShowErrorMessage( "Incomplete", "You must select a person to save a request." );
return;
}
if ( Page.IsValid )
{
using ( var rockContext = new RockContext() )
{
ConnectionRequestService connectionRequestService = new ConnectionRequestService( rockContext );
ConnectionRequest connectionRequest = null;
int connectionRequestId = hfConnectionRequestId.ValueAsInt();
// if adding a new connection request
if ( connectionRequestId.Equals( 0 ) )
{
connectionRequest = new ConnectionRequest();
connectionRequest.ConnectionOpportunityId = hfConnectionOpportunityId.ValueAsInt();
if ( ddlCampus.SelectedValueAsId().HasValue )
{
SetUserPreference( CAMPUS_SETTING, ddlCampus.SelectedValueAsId().Value.ToString() );
}
}
else
{
// load existing connection request
connectionRequest = connectionRequestService.Get( connectionRequestId );
}
var personAliasService = new PersonAliasService( rockContext );
int? oldConnectorPersonAliasId = connectionRequest.ConnectorPersonAliasId;
int? newConnectorPersonId = ddlConnectorEdit.SelectedValueAsId();
int? newConnectorPersonAliasId = newConnectorPersonId.HasValue ? personAliasService.GetPrimaryAliasId( newConnectorPersonId.Value ) : (int?)null;
connectionRequest.ConnectorPersonAliasId = newConnectorPersonAliasId;
connectionRequest.PersonAlias = personAliasService.Get( ppRequestor.PersonAliasId.Value );
connectionRequest.ConnectionState = rblState.SelectedValueAsEnum<ConnectionState>();
connectionRequest.ConnectionStatusId = rblStatus.SelectedValueAsId().Value;
if ( ddlCampus.SelectedValueAsId().HasValue )
{
connectionRequest.CampusId = ddlCampus.SelectedValueAsId().Value;
}
connectionRequest.AssignedGroupId = ddlPlacementGroup.SelectedValueAsId();
connectionRequest.AssignedGroupMemberRoleId = ddlPlacementGroupRole.SelectedValueAsInt();
connectionRequest.AssignedGroupMemberStatus = ddlPlacementGroupStatus.SelectedValueAsEnumOrNull<GroupMemberStatus>();
connectionRequest.AssignedGroupMemberAttributeValues = GetGroupMemberAttributeValues();
connectionRequest.Comments = tbComments.Text.ScrubHtmlAndConvertCrLfToBr();
connectionRequest.FollowupDate = dpFollowUp.SelectedDate;
if ( !Page.IsValid )
{
return;
}
// if the connectionRequest IsValue is false, and the UI controls didn't report any errors, it is probably
// because the custom rules of ConnectionRequest didn't pass.
// So, make sure a message is displayed in the validation summary.
cvConnectionRequest.IsValid = connectionRequest.IsValid;
if ( !cvConnectionRequest.IsValid )
{
cvConnectionRequest.ErrorMessage = connectionRequest.ValidationResults.Select( a => a.ErrorMessage ).ToList().AsDelimited( "<br />" );
return;
}
if ( connectionRequest.Id.Equals( 0 ) )
{
connectionRequestService.Add( connectionRequest );
}
rockContext.SaveChanges();
if ( newConnectorPersonAliasId.HasValue && !newConnectorPersonAliasId.Equals( oldConnectorPersonAliasId ) )
{
var guid = Rock.SystemGuid.ConnectionActivityType.ASSIGNED.AsGuid();
var assignedActivityId = new ConnectionActivityTypeService( rockContext ).Queryable()
.Where( t => t.Guid == guid )
.Select( t => t.Id )
.FirstOrDefault();
if ( assignedActivityId > 0 )
{
var connectionRequestActivityService = new ConnectionRequestActivityService( rockContext );
var connectionRequestActivity = new ConnectionRequestActivity();
connectionRequestActivity.ConnectionRequestId = connectionRequest.Id;
connectionRequestActivity.ConnectionOpportunityId = connectionRequest.ConnectionOpportunityId;
connectionRequestActivity.ConnectionActivityTypeId = assignedActivityId;
connectionRequestActivity.ConnectorPersonAliasId = newConnectorPersonAliasId;
//.........这里部分代码省略.........
示例3: btnAddConnectionRequestActivity_Click
/// <summary>
/// Handles the Click event of the btnAddConnectionRequestActivity 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 btnAddConnectionRequestActivity_Click( object sender, EventArgs e )
{
using ( var rockContext = new RockContext() )
{
var connectionRequestService = new ConnectionRequestService( rockContext );
var connectionRequestActivityService = new ConnectionRequestActivityService( rockContext );
var personAliasService = new PersonAliasService( rockContext );
var connectionRequest = connectionRequestService.Get( hfConnectionRequestId.ValueAsInt() );
if ( connectionRequest != null )
{
int? activityTypeId = ddlActivity.SelectedValueAsId();
int? personAliasId = personAliasService.GetPrimaryAliasId( ddlActivityConnector.SelectedValueAsId() ?? 0 );
if ( activityTypeId.HasValue && personAliasId.HasValue )
{
ConnectionRequestActivity connectionRequestActivity = null;
Guid? guid = hfAddConnectionRequestActivityGuid.Value.AsGuidOrNull();
if ( guid.HasValue )
{
connectionRequestActivity = connectionRequestActivityService.Get( guid.Value );
}
if ( connectionRequestActivity == null )
{
connectionRequestActivity = new ConnectionRequestActivity();
connectionRequestActivity.ConnectionRequestId = connectionRequest.Id;
connectionRequestActivity.ConnectionOpportunityId = connectionRequest.ConnectionOpportunityId;
connectionRequestActivityService.Add( connectionRequestActivity );
}
connectionRequestActivity.ConnectionActivityTypeId = activityTypeId.Value;
connectionRequestActivity.ConnectorPersonAliasId = personAliasId.Value;
connectionRequestActivity.Note = tbNote.Text;
rockContext.SaveChanges();
BindConnectionRequestActivitiesGrid( connectionRequest, rockContext );
HideDialog();
}
}
}
}
示例4: lbSave_Click
/// <summary>
/// Handles the Click event of the lbSave 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 lbSave_Click( object sender, EventArgs e )
{
if ( _group != null && _occurrence != null )
{
var rockContext = new RockContext();
var attendanceService = new AttendanceService( rockContext );
var personAliasService = new PersonAliasService( rockContext );
var existingAttendees = attendanceService.Queryable()
.Where( a =>
a.GroupId == _group.Id &&
a.ScheduleId == _group.ScheduleId &&
a.StartDateTime >= _occurrence.StartDateTime &&
a.StartDateTime < _occurrence.EndDateTime )
.ToList();
// If did not meet was selected and this was a manually entered occurrence (not based on a schedule)
// then just delete all the attendance records instead of tracking a 'did not meet' value
if ( cbDidNotMeet.Checked && !_occurrence.ScheduleId.HasValue )
{
foreach ( var attendance in existingAttendees )
{
attendanceService.Delete( attendance );
}
}
else
{
if ( cbDidNotMeet.Checked )
{
// If the occurrence is based on a schedule, set the did not meet flags
foreach ( var attendance in existingAttendees )
{
attendance.DidAttend = null;
attendance.DidNotOccur = true;
}
}
foreach ( var item in lvMembers.Items )
{
var hfMember = item.FindControl( "hfMember" ) as HiddenField;
var cbMember = item.FindControl( "cbMember" ) as CheckBox;
if ( hfMember != null && cbMember != null )
{
int personId = hfMember.ValueAsInt();
var attendance = existingAttendees
.Where( a => a.PersonAlias.PersonId == personId )
.FirstOrDefault();
if ( attendance == null )
{
int? personAliasId = personAliasService.GetPrimaryAliasId( personId );
if ( personAliasId.HasValue )
{
attendance = new Attendance();
attendance.GroupId = _group.Id;
attendance.ScheduleId = _group.ScheduleId;
attendance.PersonAliasId = personAliasId;
attendance.StartDateTime = _occurrence.StartDateTime;
attendanceService.Add( attendance );
}
}
if ( attendance != null )
{
if ( cbDidNotMeet.Checked )
{
attendance.DidAttend = null;
attendance.DidNotOccur = true;
}
else
{
attendance.DidAttend = cbMember.Checked;
attendance.DidNotOccur = null;
}
}
}
}
}
rockContext.SaveChanges();
WorkflowType workflowType = null;
Guid? workflowTypeGuid = GetAttributeValue( "Workflow" ).AsGuidOrNull();
if ( workflowTypeGuid.HasValue )
{
var workflowTypeService = new WorkflowTypeService( rockContext );
workflowType = workflowTypeService.Get( workflowTypeGuid.Value );
if ( workflowType != null )
{
try
{
var workflowService = new WorkflowService( rockContext );
var workflow = Workflow.Activate( workflowType, _group.Name );
//.........这里部分代码省略.........
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:101,代码来源:GroupAttendanceDetail.ascx.cs