Exemple #1
0
        public void Update(CarouselSettings settings, IUnitOfWork unitOfWork = null)
        {
            CarouselSlideCollection carouselSlideCollection = GetCarouselSlideCollection(settings);
            IUnitOfWork             localUnitOfWork         = unitOfWork == null?_unitOfWorkFactory.CreateUnitOfWork() : null;

            try
            {
                IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork ?? localUnitOfWork);
                string           sql = _sqlManager.GetSql("Sql.UpdateCarousel.sql");
                dbm.SetSQL(sql);
                dbm.AddParameter("@TenantId", FieldType.BigInt, settings.TenantId);
                dbm.AddParameter("@ElementId", FieldType.BigInt, settings.ElementId);
                dbm.AddTypedParameter("@CarouselSlides", FieldType.Structured, carouselSlideCollection.Count == 0 ? null : carouselSlideCollection, "element.CarouselSlideTableType");
                dbm.ExecuteNonQuery();
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Commit();
                }
            }
            catch
            {
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Rollback();
                }
                throw;
            }
            finally
            {
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Dispose();
                }
            }
        }
Exemple #2
0
        private CarouselSlideCollection GetCarouselSlideCollection(CarouselSettings settings)
        {
            CarouselSlideCollection carouselSlideCollection = new CarouselSlideCollection();

            foreach (CarouselSlide slide in settings.Slides)
            {
                carouselSlideCollection.Add(slide);
            }
            return(carouselSlideCollection);
        }