Esempio n. 1
0
    /// <summary>
    /// Executes the UnsetTragetLayout client action using parameters passed in hidden fields.
    /// </summary>
    private void UnsetTargetLayout()
    {
        int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0);

        using (var scope = new CMSTransactionScope())
        {
            LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId);
            if (sourceLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout"));
            }

            InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts()
                                                                      .WhereEquals("DeviceProfileID", DeviceProfile.ProfileID)
                                                                      .WhereEquals("SourceLayoutID", sourceLayout.LayoutId)
                                                                      .TypedResult
                                                                      .Items;

            if (bindings.Count > 0)
            {
                DeviceProfileLayoutInfoProvider.DeleteDeviceProfileLayoutInfo(bindings[0]);
            }
            scope.Commit();
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Executes the UnsetTragetLayout client action using parameters passed in hidden fields.
    /// </summary>
    private void UnsetTargetLayout()
    {
        int sourceLayoutId = ValidationHelper.GetInteger(SourceLayoutIdentifierHiddenField.Value, 0);

        using (CMSTransactionScope scope = new CMSTransactionScope())
        {
            LayoutInfo sourceLayout = LayoutInfoProvider.GetLayoutInfo(sourceLayoutId);
            if (sourceLayout == null)
            {
                throw new ApplicationException(GetString("device_profile.layoutmapping.errors.nosourcelayout"));
            }
            string condition = String.Format("DeviceProfileID = {0:D} AND SourceLayoutID = {1:D}", DeviceProfile.ProfileID, sourceLayout.LayoutId);
            InfoObjectCollection <DeviceProfileLayoutInfo> bindings = DeviceProfileLayoutInfoProvider.GetDeviceProfileLayouts(condition, null).Items;
            if (bindings.Count > 0)
            {
                DeviceProfileLayoutInfoProvider.DeleteDeviceProfileLayoutInfo(bindings[0]);
            }
            scope.Commit();
        }
    }