Esempio n. 1
0
        /// <summary>
        /// Retrieves distinct list of element identifiers that are associated with the supplied list of master page zone element identifiers.
        /// </summary>
        /// <param name="tenantId">Website tenant identifier.</param>
        /// <param name="masterPageId">Master page identifier.</param>
        /// <param name="masterPageZoneId">Master page zone identifier.</param>
        /// <param name="masterPageZoneElementIds">List of master page zone element identifiers, whose associated elements are returned.</param>
        /// <param name="unitOfWork">Unit of work.</param>
        /// <returns>Distinct list of element identifiers associated with supplied list of master page zone element identifiers.</returns>
        public List <long> ListPageElementsByMasterPageZoneElementIds(long tenantId, long masterPageId, long masterPageZoneId, List <long> masterPageZoneElementIds, IUnitOfWork unitOfWork = null)
        {
            IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork);

            try
            {
                MasterPageZoneElementCollection masterPageZoneElementCollection = new MasterPageZoneElementCollection();
                foreach (long masterPageZoneElementId in masterPageZoneElementIds)
                {
                    masterPageZoneElementCollection.Add(new MasterPageZoneElement {
                        MasterPageZoneElementId = masterPageZoneElementId
                    });
                }
                dbm.SetSQL(_sqlManager.GetSql("Sql.ListPageElementsByMasterPageZoneElementIds.sql"));
                dbm.AddParameter("@TenantId", FieldType.BigInt, tenantId);
                dbm.AddParameter("@MasterPageId", FieldType.BigInt, masterPageId);
                dbm.AddParameter("@MasterPageZoneId", FieldType.BigInt, masterPageZoneId);
                dbm.AddTypedParameter("@MasterPageZoneElements", FieldType.Structured, masterPageZoneElementCollection.Count == 0 ? null : masterPageZoneElementCollection, "cms.MasterPageZoneElementTableType");
                dbm.ExecuteReader();
                List <long> elementIds = new List <long>();
                while (dbm.Read())
                {
                    elementIds.Add((long)dbm.DataReaderValue("ElementId"));
                }
                return(elementIds);
            }
            finally
            {
                if (unitOfWork == null)
                {
                    dbm.Dispose();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Deletes page zone elements that are associated with list of master page zone element identifiers.
        /// </summary>
        /// <param name="tenantId">Website tenant identifier.</param>
        /// <param name="masterPageId">Master page identifier.</param>
        /// <param name="masterPageZoneId">Master page zone identifier.</param>
        /// <param name="masterPageZoneElementIds">List of master page zone element identifiers, identifying page zone elements to delete.</param>
        /// <param name="unitOfWork">Unit of work.</param>
        public void DeletePageZoneElementsByMasterPageZoneElementIds(long tenantId, long masterPageId, long masterPageZoneId, List <long> masterPageZoneElementIds, IUnitOfWork unitOfWork = null)
        {
            IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork);

            try
            {
                MasterPageZoneElementCollection masterPageZoneElementCollection = new MasterPageZoneElementCollection();
                foreach (long masterPageZoneElementId in masterPageZoneElementIds)
                {
                    masterPageZoneElementCollection.Add(new MasterPageZoneElement {
                        MasterPageZoneElementId = masterPageZoneElementId
                    });
                }
                dbm.SetSQL(_sqlManager.GetSql("Sql.DeletePageZoneElementsByMasterPageZoneElementIds.sql"));
                dbm.AddParameter("@TenantId", FieldType.BigInt, tenantId);
                dbm.AddParameter("@MasterPageId", FieldType.BigInt, masterPageId);
                dbm.AddParameter("@MasterPageZoneId", FieldType.BigInt, masterPageZoneId);
                dbm.AddTypedParameter("@MasterPageZoneElements", FieldType.Structured, masterPageZoneElementCollection.Count == 0 ? null : masterPageZoneElementCollection, "cms.MasterPageZoneElementTableType");
                dbm.ExecuteNonQuery();
            }
            finally
            {
                if (unitOfWork == null)
                {
                    dbm.Dispose();
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Populates zone element and zone element type collections for table types.
 /// </summary>
 /// <param name="masterPageZone">Master page zone.</param>
 /// <param name="masterPageZoneElementTypeCollection">Master page zone element type collection.</param>
 /// <param name="masterPageZoneElementCollection">Master page zone element collection.</param>
 private void PopulateMasterPageZoneCollections(MasterPageZone masterPageZone, MasterPageZoneElementTypeCollection masterPageZoneElementTypeCollection, MasterPageZoneElementCollection masterPageZoneElementCollection)
 {
     foreach (MasterPageZoneElementType masterPageZoneElementType in masterPageZone.MasterPageZoneElementTypes)
     {
         masterPageZoneElementType.MasterPageZoneSortOrder = masterPageZone.SortOrder;
         masterPageZoneElementTypeCollection.Add(masterPageZoneElementType);
     }
     foreach (MasterPageZoneElement masterPageZoneElement in masterPageZone.MasterPageZoneElements)
     {
         masterPageZoneElement.MasterPageZoneSortOrder = masterPageZone.SortOrder;
         masterPageZoneElementCollection.Add(masterPageZoneElement);
     }
 }