/// <summary> /// Gets the edit value as the IEntity.Id /// </summary> /// <param name="control">The control.</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public int?GetEditValueAsEntityId(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues) { Guid guid = GetEditValue(control, configurationValues).AsGuid(); var item = EventCalendarCache.Read(guid); return(item != null ? item.Id : (int?)null); }
/// <summary> /// Sets the edit value from IEntity.Id value /// </summary> /// <param name="control">The control.</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="id">The identifier.</param> public void SetEditValueFromEntityId(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues, int?id) { EventCalendarCache item = null; if (id.HasValue) { item = EventCalendarCache.Read(id.Value); } string guidValue = item != null?item.Guid.ToString() : string.Empty; SetEditValue(control, configurationValues, guidValue); }
/// <summary> /// Sets the value. /// Expects value as a EventCalendar.Guid as string /// </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) { EventCalendarPicker eventCalendarPicker = control as EventCalendarPicker; if (eventCalendarPicker != null) { Guid guid = value.AsGuid(); // get the item (or null) and set it var eventCalendar = EventCalendarCache.Read(guid); eventCalendarPicker.SetValue(eventCalendar == null ? "0" : eventCalendar.Id.ToString()); } }
/// <summary> /// Returns the field's current value(s) /// </summary> /// <param name="parentControl">The parent control.</param> /// <param name="value">Information about the value</param> /// <param name="configurationValues">The configuration values.</param> /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param> /// <returns></returns> public override string FormatValue(System.Web.UI.Control parentControl, string value, Dictionary <string, ConfigurationValue> configurationValues, bool condensed) { string formattedValue = value; if (!string.IsNullOrWhiteSpace(value)) { var eventCalendar = EventCalendarCache.Read(value.AsGuid()); if (eventCalendar != null) { formattedValue = eventCalendar.Name; } } return(base.FormatValue(parentControl, formattedValue, configurationValues, condensed)); }
/// <summary> /// Reads new values entered by the user for the field /// returns EventCalendar.Guid as string /// </summary> /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param> /// <param name="configurationValues">The configuration values.</param> /// <returns></returns> public override string GetEditValue(System.Web.UI.Control control, Dictionary <string, ConfigurationValue> configurationValues) { EventCalendarPicker eventCalendarPicker = control as EventCalendarPicker; if (eventCalendarPicker != null) { int?eventCalendarId = eventCalendarPicker.SelectedEventCalendarId; if (eventCalendarId.HasValue) { var eventCalendar = EventCalendarCache.Read(eventCalendarId.Value); if (eventCalendar != null) { return(eventCalendar.Guid.ToString()); } } } return(string.Empty); }