本文整理汇总了C#中Rock.Model.DefinedValueService类的典型用法代码示例。如果您正苦于以下问题:C# DefinedValueService类的具体用法?C# DefinedValueService怎么用?C# DefinedValueService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefinedValueService类属于Rock.Model命名空间,在下文中一共展示了DefinedValueService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindPackageGrid
/// <summary>
/// Binds the package grid.
/// </summary>
public void BindPackageGrid()
{
using ( var rockContext = new RockContext() )
{
var definedValues = new DefinedValueService( rockContext )
.GetByDefinedTypeGuid( Rock.SystemGuid.DefinedType.PROTECT_MY_MINISTRY_PACKAGES.AsGuid() )
.ToList();
foreach( var definedValue in definedValues )
{
definedValue.LoadAttributes( rockContext );
}
gDefinedValues.DataSource = definedValues.Select( v => new
{
v.Id,
v.Value,
v.Description,
PackageName = v.GetAttributeValue( "PMMPackageName" ),
DefaultCounty = v.GetAttributeValue( "DefaultCounty" ),
SendAddressCounty = v.GetAttributeValue( "SendHomeCounty" ).AsBoolean(),
DefaultState = v.GetAttributeValue( "DefaultState" ),
SendAddressState = v.GetAttributeValue( "SendHomeState" ).AsBoolean(),
MVRJurisdication = v.GetAttributeValue("MVRJurisdiction"),
SendAddressStateMVR = v.GetAttributeValue( "SendHomeStateMVR" ).AsBoolean()
} )
.ToList();
gDefinedValues.DataBind();
}
}
示例2: btnSaveStars_OnClick
protected void btnSaveStars_OnClick(object sender, EventArgs e)
{
// ddl
var x = Convert.ToInt32(ddlStars.SelectedItem.Value);
DefinedValueService definedValueService = new DefinedValueService(rockContext);
var definedValue = definedValueService.Queryable().FirstOrDefault(a => a.Id == x);
definedValue.LoadAttributes();
var attributeValue = definedValue.GetAttributeValue("StarValue");
var starsValue = Convert.ToDecimal(attributeValue);
var pa = Person.PrimaryAliasId;
//var pa = ppPerson.PersonAliasId;
//var value = Decimal.Parse(tbValue.Text);
StarsService starsService = new StarsService(starsProjectContext);
org.newpointe.Stars.Model.Stars stars = new org.newpointe.Stars.Model.Stars();
stars.PersonAliasId = pa.GetValueOrDefault();
stars.CampusId = 1;
stars.TransactionDateTime = DateTime.Now;
stars.Value = starsValue;
stars.Note = ddlStars.SelectedItem.Text + ". Manually added by " + CurrentPerson.FullName;
starsService.Add(stars);
starsProjectContext.SaveChanges();
//Refresh Page to update grids
Response.Redirect(Request.RawUrl);
}
示例3: OnLoad
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnLoad( EventArgs e )
{
base.OnLoad( e );
if ( Page.IsPostBack )
{
var rockContext = new RockContext();
var definedValueService = new DefinedValueService(rockContext);
foreach ( RepeaterItem item in rptrValues.Items )
{
var hfValue = item.FindControl( "hfValue" ) as HiddenField;
var cbValue = item.FindControl( "cbValue" ) as CheckBox;
if ( hfValue != null && cbValue != null )
{
var value = definedValueService.Get( hfValue.ValueAsInt() );
if ( value != null )
{
Helper.LoadAttributes( value );
if ( value.GetAttributeValue( attributeKey ) != cbValue.Checked.ToString() )
{
value.SetAttributeValue( attributeKey, cbValue.Checked.ToString() );
value.SaveAttributeValues();
DefinedValueCache.Flush( value.Id );
}
}
}
}
}
bool wasVisible = this.Visible;
ShowList();
if ( Page.IsPostBack && wasVisible && this.Visible == false )
{
// If last item was just checked do a redirect back to the same page.
// This is needed to hide the control since content is inside an update
// panel
Response.Redirect( CurrentPageReference.BuildUrl(), false );
}
}
示例4: gDefinedType_Delete
/// <summary>
/// Handles the Delete event of the gDefinedType control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gDefinedType_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
var definedValueService = new DefinedValueService( rockContext );
var definedTypeService = new DefinedTypeService( rockContext );
DefinedType type = definedTypeService.Get( e.RowKeyId );
if ( type != null )
{
string errorMessage;
if ( !definedTypeService.CanDelete( type, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Information );
return;
}
// if this DefinedType has DefinedValues, see if they can be deleted
var definedValues = definedValueService.GetByDefinedTypeId( type.Id ).ToList();
foreach ( var value in definedValues )
{
if ( !definedValueService.CanDelete( value, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Information );
return;
}
}
foreach ( var value in definedValues )
{
definedValueService.Delete( value );
}
definedTypeService.Delete( type );
rockContext.SaveChanges();
}
gDefinedType_Bind();
}
示例5: OnLoad
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
protected override void OnLoad( EventArgs e )
{
base.OnLoad( e );
if ( Page.IsPostBack )
{
var definedValueService = new DefinedValueService();
foreach ( RepeaterItem item in rptrValues.Items )
{
var hfValue = item.FindControl( "hfValue" ) as HiddenField;
var cbValue = item.FindControl( "cbValue" ) as CheckBox;
if ( hfValue != null && cbValue != null )
{
var value = definedValueService.Get( hfValue.ValueAsInt() );
if ( value != null )
{
Helper.LoadAttributes( value );
value.SetAttributeValue( attributeKey, cbValue.Checked.ToString() );
Helper.SaveAttributeValues( value, CurrentPersonId );
DefinedValueCache.Flush( value.Id );
}
}
}
}
ShowList();
if (Page.IsPostBack && pnlContent.Visible == false)
{
// If last item was just checked (postback and visible == false),
// do a redirect back to the same page. This is needed to hide
// the pre/post content which is outside of this controls update panel.
Response.Redirect( CurrentPageReference.BuildUrl(), false );
}
}
示例6: gDefinedValues_Delete
/// <summary>
/// Handles the Delete event of the gDefinedValues control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gDefinedValues_Delete( object sender, RowEventArgs e )
{
var valueService = new DefinedValueService();
DefinedValue value = valueService.Get( (int)e.RowKeyValue );
DefinedTypeCache.Flush(value.DefinedTypeId);
DefinedValueCache.Flush(value.Id);
if ( value != null )
{
valueService.Delete( value, CurrentPersonId );
valueService.Save( value, CurrentPersonId );
}
BindDefinedValuesGrid();
}
示例7: 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 )
{
var rockContext = new RockContext();
rockContext.WrapTransaction( () =>
{
var personService = new PersonService( rockContext );
var changes = new List<string>();
Person business = null;
if ( int.Parse( hfBusinessId.Value ) != 0 )
{
business = personService.Get( int.Parse( hfBusinessId.Value ) );
}
if ( business == null )
{
business = new Person();
personService.Add( business );
}
// Business Name
History.EvaluateChange( changes, "Last Name", business.LastName, tbBusinessName.Text );
business.LastName = tbBusinessName.Text;
// Phone Number
var businessPhoneTypeId = new DefinedValueService( rockContext ).GetByGuid( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK ) ).Id;
string oldPhoneNumber = string.Empty;
string newPhoneNumber = string.Empty;
var phoneNumber = business.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == businessPhoneTypeId );
if ( phoneNumber != null )
{
oldPhoneNumber = phoneNumber.NumberFormattedWithCountryCode;
}
if ( !string.IsNullOrWhiteSpace( PhoneNumber.CleanNumber( pnbPhone.Number ) ) )
{
if ( phoneNumber == null )
{
phoneNumber = new PhoneNumber { NumberTypeValueId = businessPhoneTypeId };
business.PhoneNumbers.Add( phoneNumber );
}
phoneNumber.CountryCode = PhoneNumber.CleanNumber( pnbPhone.CountryCode );
phoneNumber.Number = PhoneNumber.CleanNumber( pnbPhone.Number );
phoneNumber.IsMessagingEnabled = cbSms.Checked;
phoneNumber.IsUnlisted = cbUnlisted.Checked;
newPhoneNumber = phoneNumber.NumberFormattedWithCountryCode;
}
else
{
if ( phoneNumber != null )
{
business.PhoneNumbers.Remove( phoneNumber );
new PhoneNumberService( rockContext ).Delete( phoneNumber );
}
}
History.EvaluateChange(
changes,
string.Format( "{0} Phone", DefinedValueCache.GetName( businessPhoneTypeId ) ),
oldPhoneNumber,
newPhoneNumber );
// Record Type - this is always "business". it will never change.
business.RecordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_BUSINESS.AsGuid() ).Id;
// Record Status
int? newRecordStatusId = ddlRecordStatus.SelectedValueAsInt();
History.EvaluateChange( changes, "Record Status", DefinedValueCache.GetName( business.RecordStatusValueId ), DefinedValueCache.GetName( newRecordStatusId ) );
business.RecordStatusValueId = newRecordStatusId;
// Record Status Reason
int? newRecordStatusReasonId = null;
if ( business.RecordStatusValueId.HasValue && business.RecordStatusValueId.Value == DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ) ).Id )
{
newRecordStatusReasonId = ddlReason.SelectedValueAsInt();
}
History.EvaluateChange( changes, "Record Status Reason", DefinedValueCache.GetName( business.RecordStatusReasonValueId ), DefinedValueCache.GetName( newRecordStatusReasonId ) );
business.RecordStatusReasonValueId = newRecordStatusReasonId;
// Email
business.IsEmailActive = true;
History.EvaluateChange( changes, "Email", business.Email, tbEmail.Text );
business.Email = tbEmail.Text.Trim();
var newEmailPreference = rblEmailPreference.SelectedValue.ConvertToEnum<EmailPreference>();
History.EvaluateChange( changes, "EmailPreference", business.EmailPreference, newEmailPreference );
business.EmailPreference = newEmailPreference;
if ( business.IsValid )
{
if ( rockContext.SaveChanges() > 0 )
//.........这里部分代码省略.........
示例8: dlgPackage_SaveClick
protected void dlgPackage_SaveClick( object sender, EventArgs e )
{
int definedValueId = hfDefinedValueId.Value.AsInteger();
var definedType = DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PROTECT_MY_MINISTRY_PACKAGES.AsGuid() );
if ( definedType != null )
{
using ( var rockContext = new RockContext() )
{
var service = new DefinedValueService( rockContext );
DefinedValue definedValue = null;
if ( !definedValueId.Equals( 0 ) )
{
definedValue = service.Get( definedValueId );
}
if ( definedValue == null )
{
definedValue = new DefinedValue();
definedValue.DefinedTypeId = definedType.Id;
service.Add( definedValue );
}
definedValue.Value = tbTitle.Text;
definedValue.Description = tbDescription.Text;
rockContext.SaveChanges();
definedValue.LoadAttributes( rockContext );
Guid? dvJurisdicationCodeGuid = null;
int? dvJurisdictionCodeId = ddlMVRJurisdication.SelectedValueAsInt();
if ( dvJurisdictionCodeId.HasValue && dvJurisdictionCodeId.Value > 0 )
{
var dvJurisdicationCode = DefinedValueCache.Read( dvJurisdictionCodeId.Value );
if ( dvJurisdicationCode != null )
{
dvJurisdicationCodeGuid = dvJurisdicationCode.Guid;
}
}
definedValue.SetAttributeValue( "PMMPackageName", tbPackageName.Text );
definedValue.SetAttributeValue( "DefaultCounty", tbDefaultCounty.Text );
definedValue.SetAttributeValue( "SendHomeCounty", cbSendCounty.Checked.ToString() );
definedValue.SetAttributeValue( "DefaultState", tbDefaultState.Text );
definedValue.SetAttributeValue( "SendHomeState", cbSendState.Checked.ToString() );
definedValue.SetAttributeValue( "MVRJurisdiction", dvJurisdicationCodeGuid.HasValue ? dvJurisdicationCodeGuid.Value.ToString() : string.Empty );
definedValue.SetAttributeValue( "SendHomeStateMVR", cbSendStateMVR.Checked.ToString() );
definedValue.SaveAttributeValues( rockContext );
DefinedTypeCache.Flush( definedType.Id );
DefinedValueCache.Flush( definedValue.Id );
}
}
BindPackageGrid();
HideDialog();
}
示例9: MapAttendance
/// <summary>
/// Maps the attendance.
/// </summary>
/// <param name="tableData">The table data.</param>
/// <returns></returns>
//private DateTime? StartDateTime { get; set;}
private void MapAttendance( IQueryable<Row> tableData )
{
var lookupContext = new RockContext();
int completed = 0;
int totalRows = tableData.Count();
int percentage = ( totalRows - 1 ) / 100 + 1;
ReportProgress( 0, string.Format( "Verifying Attendance import ({0:N0} found).", totalRows ) );
var attendanceList = new List<Rock.Model.Attendance>();
var groupService = new GroupService( lookupContext );
var existingGroupList = new List<Group>();
existingGroupList = groupService.Queryable().ToList();
foreach ( var row in tableData )
{
DateTime? startTime = row["Start_Date_Time"] as DateTime?;
if ( startTime != null && startTime != DateTime.MinValue)
{
DateTime startDateTime = (DateTime)startTime;
if ( startDateTime.Year == 2014 && startDateTime.Month >= 1 && startDateTime.Month <= 8 )
{
//startDateTime = BruteForceDateTime(startTime);
var attendance = new Rock.Model.Attendance();
attendance.CreatedByPersonAliasId = ImportPersonAlias.Id;
attendance.ModifiedByPersonAliasId = ImportPersonAlias.Id;
attendance.CreatedDateTime = DateTime.Today;
attendance.ModifiedDateTime = DateTime.Today;
attendance.StartDateTime = startDateTime; //(DateTime)startTime;
attendance.DidAttend = true;
attendance.CampusId = 1; //Campus is needed for attendance to show in attendance analysis.
//string position = row["CheckedInAs"] as string;
//string jobTitle = row["Job_Title"] as string;
//string machineName = row["Checkin_Machine_Name"] as string;
int? rlcId = row["RLC_ID"] as int?;
int? individualId = row["Individual_ID"] as int?;
if ( individualId != null )
{
attendance.PersonAliasId = GetPersonAliasId( individualId );
}
DateTime? checkInTime = row["Check_In_Time"] as DateTime?;
if ( checkInTime != null )
{
// set the start time to the time they actually checked in. If null it maintains Start_Date_Time
attendance.StartDateTime = (DateTime)checkInTime; //BruteForceDateTime( checkInTime );
}
DateTime? checkOutTime = row["Check_Out_Time"] as DateTime?;
if ( checkOutTime != null )
{
attendance.EndDateTime = (DateTime)checkOutTime; //BruteForceDateTime( checkOutTime );
}
//string f1AttendanceCode = row["Tag_Code"] as string;
//if ( f1AttendanceCode != null )
//{
// attendance.AttendanceCode = new Rock.Model.AttendanceCode();
// attendance.AttendanceCode.Code = f1AttendanceCode;
//}
string f1AttendanceCheckedInAs = row["CheckedInAs"] as string;
if ( f1AttendanceCheckedInAs != null )
{
attendance.Note = f1AttendanceCheckedInAs;
}
// look up location, schedule, and device -- all of these fields can be null if need be
attendance.LocationId = GetLocationId( Convert.ToInt32( rlcId ) );
//look up Group
Group rlcGroup = existingGroupList.Where( g => g.ForeignId == ( rlcId.ToString() ) ).FirstOrDefault();
if ( rlcGroup != null )
{
attendance.GroupId = rlcGroup.Id;
}
var dvService = new DefinedValueService( lookupContext );
attendance.SearchTypeValueId = dvService.Queryable().Where( dv => dv.Value == "Phone Number" ).FirstOrDefault().Id;
//ReportProgress( 0, string.Format( "{0},{1},{2},{3},{4},{5},{6},{7},{8}", individualId,rlcId,rlcGroup.Name,attendance.CreatedByPersonAliasId,attendance.ModifiedByPersonAliasId,attendance.StartDateTime,attendance.DidAttend,attendance.AttendanceCode,attendance.LocationId ) );
//look into creating DeviceIds and Locations (Generic)
// Other Attributes to create:
// Tag_Comment
// BreakoutGroup_Name
// Pager_Code
//.........这里部分代码省略.........
示例10: LoadDropDowns
/// <summary>
/// Loads the drop downs.
/// </summary>
private void LoadDropDowns( int? groupTypeId )
{
ddlAttendanceRule.BindToEnum<Rock.Model.AttendanceRule>();
cblScheduleTypes.Items.Clear();
cblScheduleTypes.Items.Add( new ListItem( "Weekly", "1" ) );
cblScheduleTypes.Items.Add( new ListItem( "Custom", "2" ) );
cblScheduleTypes.Items.Add( new ListItem( "Named", "4" ) );
cblLocationSelectionModes.Items.Clear();
cblLocationSelectionModes.Items.Add( new ListItem( "Named", "2" ) );
cblLocationSelectionModes.Items.Add( new ListItem( "Address", "1" ) );
cblLocationSelectionModes.Items.Add( new ListItem( "Point", "4" ) );
cblLocationSelectionModes.Items.Add( new ListItem( "Geo-fence", "8" ) );
cblLocationSelectionModes.Items.Add( new ListItem( "Group Member Address", "16" ) );
var rockContext = new RockContext();
gtpInheritedGroupType.GroupTypes = new GroupTypeService( rockContext ).Queryable()
.Where( g => g.Id != groupTypeId )
.ToList();
var groupTypePurposeList = new DefinedValueService( rockContext ).GetByDefinedTypeGuid( new Guid( Rock.SystemGuid.DefinedType.GROUPTYPE_PURPOSE ) ).OrderBy( a => a.Value ).ToList();
ddlGroupTypePurpose.Items.Clear();
ddlGroupTypePurpose.Items.Add( Rock.Constants.None.ListItem );
foreach ( var item in groupTypePurposeList )
{
ddlGroupTypePurpose.Items.Add( new ListItem( item.Value, item.Id.ToString() ) );
}
}
示例11: EditControl
/// <summary>
/// Creates the control(s) neccessary for prompting user for a new value
/// </summary>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="id"></param>
/// <returns>
/// The control
/// </returns>
public override Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
{
ListControl editControl;
if ( configurationValues != null && configurationValues.ContainsKey( ALLOW_MULTIPLE_KEY ) && configurationValues[ ALLOW_MULTIPLE_KEY ].Value.AsBoolean() )
{
editControl = new Rock.Web.UI.Controls.RockCheckBoxList { ID = id };
editControl.AddCssClass( "checkboxlist-group" );
}
else
{
editControl = new Rock.Web.UI.Controls.RockDropDownList { ID = id };
editControl.Items.Add( new ListItem() );
}
if ( configurationValues != null && configurationValues.ContainsKey( DEFINED_TYPE_KEY ) )
{
int definedTypeId = 0;
if ( Int32.TryParse( configurationValues[DEFINED_TYPE_KEY].Value, out definedTypeId ) )
{
Rock.Model.DefinedValueService definedValueService = new Model.DefinedValueService();
foreach ( var definedValue in definedValueService.GetByDefinedTypeId( definedTypeId ) )
{
editControl.Items.Add( new ListItem( definedValue.Name, definedValue.Id.ToString() ) );
}
}
}
return editControl;
}
示例12: BindDefinedValuesGrid
/// <summary>
/// Binds the defined values grid.
/// </summary>
protected void BindDefinedValuesGrid()
{
AttributeService attributeService = new AttributeService();
int definedTypeId = hfDefinedTypeId.ValueAsInt();
// add attributes with IsGridColumn to grid
string qualifierValue = hfDefinedTypeId.Value;
var qryDefinedTypeAttributes = attributeService.GetByEntityTypeId( new DefinedValue().TypeId ).AsQueryable()
.Where( a => a.EntityTypeQualifierColumn.Equals( "DefinedTypeId", StringComparison.OrdinalIgnoreCase )
&& a.EntityTypeQualifierValue.Equals( qualifierValue ) );
qryDefinedTypeAttributes = qryDefinedTypeAttributes.Where( a => a.IsGridColumn );
List<Attribute> gridItems = qryDefinedTypeAttributes.ToList();
foreach ( var item in gDefinedValues.Columns.OfType<AttributeField>().ToList() )
{
gDefinedValues.Columns.Remove( item );
}
foreach ( var item in gridItems.OrderBy( a => a.Order ).ThenBy( a => a.Name ) )
{
string dataFieldExpression = item.Key;
bool columnExists = gDefinedValues.Columns.OfType<AttributeField>().FirstOrDefault( a => a.DataField.Equals( dataFieldExpression ) ) != null;
if ( !columnExists )
{
AttributeField boundField = new AttributeField();
boundField.DataField = dataFieldExpression;
boundField.HeaderText = item.Name;
boundField.SortExpression = string.Empty;
int insertPos = gDefinedValues.Columns.IndexOf( gDefinedValues.Columns.OfType<DeleteField>().First());
gDefinedValues.Columns.Insert(insertPos, boundField );
}
}
var queryable = new DefinedValueService().Queryable().Where( a => a.DefinedTypeId == definedTypeId ).OrderBy( a => a.Order );
var result = queryable.ToList();
gDefinedValues.DataSource = result;
gDefinedValues.DataBind();
}
示例13: 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();
}
示例14: GetSpouse
/// <summary>
/// Gets the <see cref="Rock.Model.Person"/> entity of the provided Person's spouse.
/// </summary>
/// <param name="person">The <see cref="Rock.Model.Person"/> entity of the Person to retrieve the spouse of.</param>
/// <returns>The <see cref="Rock.Model.Person"/> entity containing the provided Person's spouse. If the provided Person's spouse is not found, this value will be null.</returns>
public Person GetSpouse( Person person )
{
// Spouse is determined if all these conditions are met
// 1) Adult in the same family as Person (GroupType = Family, GroupRole = Adult, and in same Group)
// 2) Opposite Gender as Person
// 3) Both Persons are Married
Guid adultGuid = new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT );
Guid marriedGuid = new Guid(Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED);
int marriedDefinedValueId = new DefinedValueService().Queryable().First(a => a.Guid == marriedGuid).Id;
if ( person.MaritalStatusValueId != marriedDefinedValueId )
{
return null;
}
return GetFamilyMembers(person)
.Where( m => m.GroupRole.Guid == adultGuid)
.Where( m => m.Person.Gender != person.Gender )
.Where( m => m.Person.MaritalStatusValueId == marriedDefinedValueId)
.Select( m => m.Person )
.FirstOrDefault();
}
示例15: AddDefinedTypeValue
/// <summary>
/// Adds a new defined value to a given DefinedType.
/// </summary>
/// <param name="topic">the string value of the new defined value</param>
/// <param name="definedTypeCache">a defined type cache to which the defined value will be added.</param>
/// <param name="rockContext"></param>
/// <returns></returns>
private DefinedValueCache AddDefinedTypeValue( string topic, DefinedTypeCache definedTypeCache, RockContext rockContext )
{
DefinedValueService definedValueService = new DefinedValueService( rockContext );
DefinedValue definedValue = new DefinedValue {
Id = 0,
IsSystem = false,
Value = topic,
Description = "",
CreatedDateTime = RockDateTime.Now,
DefinedTypeId = definedTypeCache.Id
};
definedValueService.Add( definedValue );
rockContext.SaveChanges();
Rock.Web.Cache.DefinedValueCache.Flush( definedValue.Id );
Rock.Web.Cache.DefinedTypeCache.Flush( definedTypeCache.Id );
return DefinedValueCache.Read( definedValue.Id, rockContext );
}