本文整理汇总了C#中Rock.Model.LocationService.IsAuthorized方法的典型用法代码示例。如果您正苦于以下问题:C# LocationService.IsAuthorized方法的具体用法?C# LocationService.IsAuthorized怎么用?C# LocationService.IsAuthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.LocationService
的用法示例。
在下文中一共展示了LocationService.IsAuthorized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDetail
/// <summary>
/// Shows the detail.
/// </summary>
/// <param name="itemKey">The item key.</param>
/// <param name="itemKeyValue">The location id.</param>
public void ShowDetail( string itemKey, int itemKeyValue, int? parentLocationId )
{
pnlDetails.Visible = false;
if ( !itemKey.Equals( "LocationId" ) )
{
return;
}
bool editAllowed = true;
Location location = null;
if ( !itemKeyValue.Equals( 0 ) )
{
location = new LocationService( new RockContext() ).Get( itemKeyValue );
if ( location != null )
{
editAllowed = location.IsAuthorized( Authorization.EDIT, CurrentPerson );
}
}
else
{
location = new Location { Id = 0, IsActive = true, ParentLocationId = parentLocationId };
}
if ( location == null )
{
return;
}
pnlDetails.Visible = true;
hfLocationId.Value = location.Id.ToString();
// render UI based on Authorized and IsSystem
bool readOnly = false;
nbEditModeMessage.Text = string.Empty;
if ( !editAllowed || !IsUserAuthorized( Authorization.EDIT ) )
{
readOnly = true;
nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( Location.FriendlyTypeName );
}
if ( readOnly )
{
btnEdit.Visible = false;
btnDelete.Visible = false;
ShowReadonlyDetails( location );
}
else
{
btnEdit.Visible = true;
btnDelete.Visible = true;
if ( location.Id > 0 )
{
ShowReadonlyDetails( location );
}
else
{
ShowEditDetails( location );
}
}
}