/// <summary> /// Sets the value. /// </summary> /// <param name="control">The control.</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="value">The value.</param> public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value) { if (value != null) { PersonPicker ppPerson = control as PersonPicker; if (ppPerson != null) { Guid personGuid = Guid.Empty; Guid.TryParse(value, out personGuid); var person = new PersonService().Get(personGuid); ppPerson.SetValue(person); } } }
/// <summary> /// Sets the value (as PersonAlias.Guid) /// </summary> /// <param name="control">The control.</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="value">The value.</param> public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value) { if (value != null) { PersonPicker ppPerson = control as PersonPicker; if (ppPerson != null) { Guid guid = Guid.Empty; Guid.TryParse(value, out guid); var person = new PersonAliasService(new RockContext()).Queryable() .Where(a => a.Guid.Equals(guid)) .Select(a => a.Person) .FirstOrDefault(); ppPerson.SetValue(person); } } }
/// <summary> /// Sets the value (as PersonAlias.Guid) /// </summary> /// <param name="control">The control.</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="value">The value.</param> public override void SetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, string value) { PersonPicker ppPerson = control as PersonPicker; if (ppPerson != null) { Person person = null; Guid? personAliasGuid = value.AsGuidOrNull(); if (personAliasGuid.HasValue) { using (var rockContext = new RockContext()) { person = new PersonAliasService(rockContext).Queryable() .Where(a => a.Guid == personAliasGuid.Value) .Select(a => a.Person) .FirstOrDefault(); } } ppPerson.SetValue(person); } }