Exemple #1
0
        public void HandleEvent(ModelBoundEvent eventMessage)
        {
            if (!eventMessage.BoundModel.CustomProperties.ContainsKey("GMC"))
            {
                return;
            }

            var model = eventMessage.BoundModel.CustomProperties["GMC"] as GoogleProductModel;

            if (model == null)
            {
                return;
            }

            var utcNow = DateTime.UtcNow;
            var entity = _googleService.GetGoogleProductRecord(model.ProductId);
            var insert = (entity == null);

            if (entity == null)
            {
                entity = new GoogleProductRecord
                {
                    ProductId    = model.ProductId,
                    CreatedOnUtc = utcNow
                };
            }

            // map objects
            entity.AgeGroup     = model.AgeGroup;
            entity.Color        = model.Color;
            entity.Gender       = model.Gender;
            entity.Size         = model.Size;
            entity.Taxonomy     = model.Taxonomy;
            entity.Material     = model.Material;
            entity.Pattern      = model.Pattern;
            entity.Export       = model.Exporting;
            entity.UpdatedOnUtc = utcNow;

            entity.IsTouched = entity.IsTouched();

            if (!insert && !entity.IsTouched)
            {
                _googleService.DeleteGoogleProductRecord(entity);
                return;
            }

            if (insert)
            {
                _googleService.InsertGoogleProductRecord(entity);
            }
            else
            {
                _googleService.UpdateGoogleProductRecord(entity);
            }
        }
Exemple #2
0
        public void HandleEvent(ModelBoundEvent eventMessage)
        {
            if (!eventMessage.BoundModel.CustomProperties.ContainsKey("DevTools"))
            {
                return;
            }

            var model = eventMessage.BoundModel.CustomProperties["DevTools"] as BackendExtensionModel;

            if (model == null)
            {
                return;
            }

            // Do something with the model now: e.g. store it ;-)
        }
Exemple #3
0
        public void HandleEvent(ModelBoundEvent eventMessage)
        {
            if (!eventMessage.BoundModel.CustomProperties.ContainsKey("CustomBanner"))
            {
                return;
            }
            PictureEditTabModel model = eventMessage.BoundModel.CustomProperties["CustomBanner"] as PictureEditTabModel;

            if (model == null)
            {
                return;
            }
            if (!this._permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
            {
                return;
            }
            this._settingService.LoadSetting <CustomBannerSettings>(this._siteContext.CurrentSite.Id);
            DateTime           utcNow = DateTime.UtcNow;
            CustomBannerRecord entity = this._customBannerService.GetCustomBannerRecord(model.EntityId, model.EntityName);
            bool insert = entity == null;

            if (entity == null)
            {
                entity = new CustomBannerRecord
                {
                    EntityId     = model.EntityId,
                    EntityName   = model.EntityName,
                    CreatedOnUtc = utcNow
                };
            }
            entity.AddEntitySysParam(true, true);
            entity.PictureId = model.PictureId;
            if (insert)
            {
                this._customBannerService.InsertCustomBannerRecord(entity);
                return;
            }
            this._customBannerService.UpdateCustomBannerRecord(entity);
        }
Exemple #4
0
        public void HandleEvent(ModelBoundEvent eventMessage)
        {
            if (!eventMessage.BoundModel.CustomProperties.ContainsKey("GMC"))
            {
                return;
            }

            var model = eventMessage.BoundModel.CustomProperties["GMC"] as GoogleProductModel;

            if (model == null)
            {
                return;
            }

            var utcNow = DateTime.UtcNow;
            var entity = _googleService.GetGoogleProductRecord(model.ProductId);
            var insert = (entity == null);

            if (entity == null)
            {
                entity = new GoogleProductRecord
                {
                    ProductId    = model.ProductId,
                    CreatedOnUtc = utcNow
                };
            }

            entity.AgeGroup              = model.AgeGroup;
            entity.Color                 = model.Color;
            entity.Gender                = model.Gender;
            entity.Size                  = model.Size;
            entity.Taxonomy              = model.Taxonomy;
            entity.Material              = model.Material;
            entity.Pattern               = model.Pattern;
            entity.Export                = model.Export2;
            entity.UpdatedOnUtc          = utcNow;
            entity.Multipack             = model.Multipack2 ?? 0;
            entity.IsBundle              = model.IsBundle;
            entity.IsAdult               = model.IsAdult;
            entity.EnergyEfficiencyClass = model.EnergyEfficiencyClass;
            entity.CustomLabel0          = model.CustomLabel0;
            entity.CustomLabel1          = model.CustomLabel1;
            entity.CustomLabel2          = model.CustomLabel2;
            entity.CustomLabel3          = model.CustomLabel3;
            entity.CustomLabel4          = model.CustomLabel4;

            entity.IsTouched = entity.IsTouched();

            if (!insert && !entity.IsTouched)
            {
                _googleService.DeleteGoogleProductRecord(entity);
                return;
            }

            if (insert)
            {
                _googleService.InsertGoogleProductRecord(entity);
            }
            else
            {
                _googleService.UpdateGoogleProductRecord(entity);
            }
        }