本文整理汇总了C#中Location.CopyPropertiesFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Location.CopyPropertiesFrom方法的具体用法?C# Location.CopyPropertiesFrom怎么用?C# Location.CopyPropertiesFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.CopyPropertiesFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: dlgLocations_SaveClick
/// <summary>
/// Handles the SaveClick event of the dlgLocations 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 dlgLocations_SaveClick( object sender, EventArgs e )
{
Location location = null;
int? memberPersonId = null;
RockContext rockContext = new RockContext();
if ( LocationTypeTab.Equals( MEMBER_LOCATION_TAB_TITLE ) )
{
if ( ddlMember.SelectedValue != null )
{
var ids = ddlMember.SelectedValue.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries );
if ( ids.Length == 2 )
{
var dbLocation = new LocationService( rockContext ).Get( int.Parse( ids[0] ) );
if ( dbLocation != null )
{
location = new Location();
location.CopyPropertiesFrom( dbLocation );
}
memberPersonId = int.Parse( ids[1] );
}
}
}
else
{
if ( locpGroupLocation.Location != null )
{
location = new Location();
location.CopyPropertiesFrom( locpGroupLocation.Location );
}
}
if ( location != null )
{
GroupLocation groupLocation = null;
Guid guid = hfAddLocationGroupGuid.Value.AsGuid();
if ( !guid.IsEmpty() )
{
groupLocation = GroupLocationsState.FirstOrDefault( l => l.Guid.Equals( guid ) );
}
if ( groupLocation == null )
{
groupLocation = new GroupLocation();
GroupLocationsState.Add( groupLocation );
}
groupLocation.GroupMemberPersonId = memberPersonId;
groupLocation.Location = location;
groupLocation.LocationId = groupLocation.Location.Id;
groupLocation.GroupLocationTypeValueId = ddlLocationType.SelectedValueAsId();
if ( groupLocation.GroupLocationTypeValueId.HasValue )
{
groupLocation.GroupLocationTypeValue = new DefinedValue();
var definedValue = new DefinedValueService( rockContext ).Get( groupLocation.GroupLocationTypeValueId.Value );
if ( definedValue != null )
{
groupLocation.GroupLocationTypeValue.CopyPropertiesFrom( definedValue );
}
}
}
BindLocationsGrid();
HideDialog();
}
示例2: dlgLocations_SaveClick
/// <summary>
/// Handles the SaveClick event of the dlgLocations 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 dlgLocations_SaveClick( object sender, EventArgs e )
{
Location location = null;
int? memberPersonAliasId = null;
RockContext rockContext = new RockContext();
if ( LocationTypeTab.Equals( MEMBER_LOCATION_TAB_TITLE ) )
{
if ( ddlMember.SelectedValue != null )
{
var ids = ddlMember.SelectedValue.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries ).AsIntegerList().ToArray();
if ( ids.Length == 2 )
{
int locationId = ids[0];
int primaryAliasId = ids[1];
var dbLocation = new LocationService( rockContext ).Get( locationId );
if ( dbLocation != null )
{
location = new Location();
location.CopyPropertiesFrom( dbLocation );
}
memberPersonAliasId = new PersonAliasService( rockContext ).GetPrimaryAliasId( primaryAliasId );
}
}
}
else
{
if ( locpGroupLocation.Location != null )
{
location = new Location();
location.CopyPropertiesFrom( locpGroupLocation.Location );
}
}
if ( location != null )
{
GroupLocation groupLocation = null;
Guid guid = hfAddLocationGroupGuid.Value.AsGuid();
if ( !guid.IsEmpty() )
{
groupLocation = GroupLocationsState.FirstOrDefault( l => l.Guid.Equals( guid ) );
}
if ( groupLocation == null )
{
groupLocation = new GroupLocation();
GroupLocationsState.Add( groupLocation );
}
groupLocation.GroupMemberPersonAliasId = memberPersonAliasId;
groupLocation.Location = location;
groupLocation.LocationId = groupLocation.Location.Id;
groupLocation.GroupLocationTypeValueId = ddlLocationType.SelectedValueAsId();
var selectedIds = spSchedules.SelectedValuesAsInt();
groupLocation.Schedules = new ScheduleService( rockContext ).Queryable()
.Where( s => selectedIds.Contains( s.Id ) ).ToList();
if ( groupLocation.GroupLocationTypeValueId.HasValue )
{
groupLocation.GroupLocationTypeValue = new DefinedValue();
var definedValue = new DefinedValueService( rockContext ).Get( groupLocation.GroupLocationTypeValueId.Value );
if ( definedValue != null )
{
groupLocation.GroupLocationTypeValue.CopyPropertiesFrom( definedValue );
}
}
}
BindLocationsGrid();
HideDialog();
}