本文整理汇总了C#中Rock.Model.LocationService.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LocationService.ToString方法的具体用法?C# LocationService.ToString怎么用?C# LocationService.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.LocationService
的用法示例。
在下文中一共展示了LocationService.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnRegister_Click
/// <summary>
/// Handles the Click event of the btnRegister 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 btnRegister_Click( object sender, EventArgs e )
{
if ( Page.IsValid )
{
var rockContext = new RockContext();
var personService = new PersonService( rockContext );
Person person = null;
Person spouse = null;
Group family = null;
GroupLocation homeLocation = null;
var changes = new List<string>();
var spouseChanges = new List<string>();
var familyChanges = new List<string>();
// Only use current person if the name entered matches the current person's name and autofill mode is true
if ( _autoFill )
{
if ( CurrentPerson != null &&
tbFirstName.Text.Trim().Equals( CurrentPerson.FirstName.Trim(), StringComparison.OrdinalIgnoreCase ) &&
tbLastName.Text.Trim().Equals( CurrentPerson.LastName.Trim(), StringComparison.OrdinalIgnoreCase ) )
{
person = personService.Get( CurrentPerson.Id );
}
}
// Try to find person by name/email
if ( person == null )
{
var matches = personService.GetByMatch( tbFirstName.Text.Trim(), tbLastName.Text.Trim(), tbEmail.Text.Trim() );
if ( matches.Count() == 1 )
{
person = matches.First();
}
}
// Check to see if this is a new person
if ( person == null )
{
// If so, create the person and family record for the new person
person = new Person();
person.FirstName = tbFirstName.Text.Trim();
person.LastName = tbLastName.Text.Trim();
person.Email = tbEmail.Text.Trim();
person.IsEmailActive = true;
person.EmailPreference = EmailPreference.EmailAllowed;
person.RecordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON.AsGuid() ).Id;
person.ConnectionStatusValueId = _dvcConnectionStatus.Id;
person.RecordStatusValueId = _dvcRecordStatus.Id;
person.Gender = Gender.Unknown;
family = PersonService.SaveNewPerson( person, rockContext, _group.CampusId, false );
}
else
{
// updating current existing person
History.EvaluateChange( changes, "Email", person.Email, tbEmail.Text );
person.Email = tbEmail.Text;
// Get the current person's families
var families = person.GetFamilies( rockContext );
// If address can being entered, look for first family with a home location
if ( !IsSimple )
{
foreach ( var aFamily in families )
{
homeLocation = aFamily.GroupLocations
.Where( l =>
l.GroupLocationTypeValueId == _homeAddressType.Id &&
l.IsMappedLocation )
.FirstOrDefault();
if ( homeLocation != null )
{
family = aFamily;
break;
}
}
}
// If a family wasn't found with a home location, use the person's first family
if ( family == null )
{
family = families.FirstOrDefault();
}
}
// If using a 'Full' view, save the phone numbers and address
if ( !IsSimple )
{
SetPhoneNumber( rockContext, person, pnHome, null, Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME.AsGuid(), changes );
SetPhoneNumber( rockContext, person, pnCell, cbSms, Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE.AsGuid(), changes );
string oldLocation = homeLocation != null ? homeLocation.Location.ToString() : string.Empty;
//.........这里部分代码省略.........
示例2: FormatSelection
/// <summary>
/// Formats the selection.
/// </summary>
/// <param name="entityType">Type of the entity.</param>
/// <param name="selection">The selection.</param>
/// <returns></returns>
public override string FormatSelection( Type entityType, string selection )
{
string result = "Distance From";
string[] selectionValues = selection.Split( '|' );
if ( selectionValues.Length >= 2 )
{
Guid locationGuid = selectionValues[0].AsGuid();
var location = new LocationService( new RockContext() ).Get( locationGuid );
double miles = selectionValues[1].AsDoubleOrNull() ?? 0;
result = string.Format( "Within {0} miles from location: {1}", miles, location != null ? location.ToString() : string.Empty );
}
return result;
}
示例3: lbSave_Click
//.........这里部分代码省略.........
{
if ( changes.Any() )
{
HistoryService.SaveChanges(
rockContext,
typeof( Person ),
Rock.SystemGuid.Category.HISTORY_PERSON_DEMOGRAPHIC_CHANGES.AsGuid(),
business.Id,
changes );
}
}
}
// Add/Update Family Group
var familyGroupType = GroupTypeCache.GetFamilyGroupType();
int adultRoleId = familyGroupType.Roles
.Where( r => r.Guid.Equals( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid() ) )
.Select( r => r.Id )
.FirstOrDefault();
var adultFamilyMember = UpdateGroupMember( business.Id, familyGroupType, business.LastName + " Business", ddlCampus.SelectedValueAsInt(), adultRoleId, rockContext );
business.GivingGroup = adultFamilyMember.Group;
// Add/Update Known Relationship Group Type
var knownRelationshipGroupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_KNOWN_RELATIONSHIPS.AsGuid() );
int knownRelationshipOwnerRoleId = knownRelationshipGroupType.Roles
.Where( r => r.Guid.Equals( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER.AsGuid() ) )
.Select( r => r.Id )
.FirstOrDefault();
var knownRelationshipOwner = UpdateGroupMember( business.Id, knownRelationshipGroupType, "Known Relationship", null, knownRelationshipOwnerRoleId, rockContext );
// Add/Update Implied Relationship Group Type
var impliedRelationshipGroupType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_IMPLIED_RELATIONSHIPS.AsGuid() );
int impliedRelationshipOwnerRoleId = impliedRelationshipGroupType.Roles
.Where( r => r.Guid.Equals( Rock.SystemGuid.GroupRole.GROUPROLE_IMPLIED_RELATIONSHIPS_OWNER.AsGuid() ) )
.Select( r => r.Id )
.FirstOrDefault();
var impliedRelationshipOwner = UpdateGroupMember( business.Id, impliedRelationshipGroupType, "Implied Relationship", null, impliedRelationshipOwnerRoleId, rockContext );
rockContext.SaveChanges();
// Every business should have an alias record with same id. If it's missing, create it
if ( !business.Aliases.Any( a => a.AliasPersonId == business.Id ) )
{
// refetch the business to make sure we have an Id
business = personService.Get( business.Id );
if ( business != null )
{
business.Aliases.Add( new PersonAlias { AliasPersonId = business.Id, AliasPersonGuid = business.Guid } );
rockContext.SaveChanges();
}
}
// Location
int workLocationTypeId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_WORK ).Id;
var groupLocationService = new GroupLocationService( rockContext );
var workLocation = groupLocationService.Queryable( "Location" )
.Where( gl =>
gl.GroupId == adultFamilyMember.Group.Id &&
gl.GroupLocationTypeValueId == workLocationTypeId )
.FirstOrDefault();
if ( string.IsNullOrWhiteSpace( acAddress.Street1 ) )
{
if ( workLocation != null )
{
groupLocationService.Delete( workLocation );
History.EvaluateChange( changes, "Address", workLocation.Location.ToString(), string.Empty );
}
}
else
{
var oldValue = string.Empty;
var newLocation = new LocationService( rockContext ).Get(
acAddress.Street1, acAddress.Street2, acAddress.City, acAddress.State, acAddress.PostalCode, acAddress.Country );
if ( workLocation != null )
{
oldValue = workLocation.Location.ToString();
}
else
{
workLocation = new GroupLocation();
groupLocationService.Add( workLocation );
workLocation.GroupId = adultFamilyMember.Group.Id;
workLocation.GroupLocationTypeValueId = workLocationTypeId;
}
workLocation.Location = newLocation;
History.EvaluateChange( changes, "Address", oldValue, newLocation.ToString() );
}
rockContext.SaveChanges();
hfBusinessId.Value = business.Id.ToString();
} );
ShowSummary( hfBusinessId.Value.AsInteger() );
}
示例4: FormatSelection
/// <summary>
/// Formats the selection.
/// </summary>
/// <param name="entityType">Type of the entity.</param>
/// <param name="selection">The selection.</param>
/// <returns></returns>
public override string FormatSelection( Type entityType, string selection )
{
string result = "Distance From";
string[] selectionValues = selection.Split( '|' );
if ( selectionValues.Length >= 2 )
{
int? locationId = selectionValues[0].AsInteger();
var location = new LocationService().Get( locationId ?? 0 );
double miles = 0;
double.TryParse( selectionValues[1], out miles );
result = string.Format( "Within {0} miles from location: {1}", miles, location != null ? location.ToString() : string.Empty );
}
return result;
}