예제 #1
0
        public ActionResult VideoCreate(ProductVideoRecordModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(Content("Access denied"));
            }

            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            var productVideoRecord = new ProductVideoRecord
            {
                ProductId          = model.ProductId,
                EmbedVideoHtmlCode = model.EmbedVideoHtmlCode,
                VideoThumbId       = model.VideoThumbId,
                DisplayOrder       = model.DisplayOrder
            };

            _productVideoRecordService.InsertProductVideoRecord(productVideoRecord);

            SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));

            //redisplay the form
            return(View("~/Plugins/Widgets.BsProductVideo/Views/ProductVideo/VideoCreate.cshtml", model));
        }
예제 #2
0
        public ActionResult VideoCreate(int productId = 0)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(Content("Access denied"));
            }

            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(Content("Access denied"));
            }

            var model = new ProductVideoRecordModel();

            model.ProductId = productId;

            return(View("~/Plugins/Widgets.BsProductVideo/Views/ProductVideo/VideoCreate.cshtml", model));
        }
예제 #3
0
        public ActionResult ProductVideoRecordUpdate(ProductVideoRecordModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(Content("Access denied"));
            }

            var productVideoRecor = _productVideoRecordService.GetById(model.Id);

            if (productVideoRecor != null)
            {
                //productVideoRecor.ProductId = model.ProductId;
                productVideoRecor.EmbedVideoHtmlCode = model.EmbedVideoHtmlCode;
                productVideoRecor.DisplayOrder       = model.DisplayOrder;

                _productVideoRecordService.UpdateProductVideoRecord(productVideoRecor);
            }

            return(new NullJsonResult());
        }
예제 #4
0
        public ActionResult ProductVideoRecordList(DataSourceRequest command, int productId = 0)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(Content("Access denied"));
            }

            var productVideoRecords = _productVideoRecordService.GetProductVideoRecords(pageIndex: command.Page - 1,
                                                                                        pageSize: command.PageSize, productId: productId);
            var productsModel = productVideoRecords
                                .Select(x =>
            {
                var model = new ProductVideoRecordModel()
                {
                    Id                 = x.Id,
                    ProductId          = x.ProductId,
                    EmbedVideoHtmlCode = x.EmbedVideoHtmlCode,
                    VideoThumbId       = x.VideoThumbId,
                    VideoThumbUrl      = _pictureService.GetPictureUrl(x.VideoThumbId, 100),
                    DisplayOrder       = x.DisplayOrder
                };
                var product = _productService.GetProductById(x.ProductId);
                if (product != null)
                {
                    model.ProductName = product.Name;
                }

                return(model);
            })
                                .ToList();

            var gridModel = new DataSourceResult
            {
                Data  = productsModel,
                Total = productVideoRecords.TotalCount
            };

            return(Json(gridModel));
        }